This topic is locked

Processing each row on a List page

11/4/2009 9:48:28 AM
PHPRunner General questions
D
daviesgh author

I am upgrading a project from PHPRunner 4.1 (320) to PHPRunner 5.1 (2503)
On a List page, for each row, I want to either display a text message, a hyperlink or nothing depending on the values in that row. Previously in PHPrunner 4.1, I inserted the Smarty 'if else' command into the HTML List Page, and that evaluated each row.
How do I do this using the new template commands? There does not appear to be 'if else' in the new template commands. Do I have to create a dummy field and use a custom function to populate it?
Regards
Gordon

Sergey Kornilov admin 11/4/2009

Gordon,
you can insert a template variable in HTML template and then populate it in BeforeProcessList event.
In HTML template:

{$variable_name}
In BeforeProcessList event:

global $xt;

$xt->assign('variable_name', 'Something');
All logic needs to be implemented in PHP code in BeforeProcessList event.
More info:

http://www.xlinesoft.com/phprunner/docs/smarty_templates.htm

D
daviesgh author 11/4/2009

Sergey,
In my example I have a list page with 10 rows. In row 1, field a=1, so text should be displayed in row 1. In row 2, field a=2, so a hyperlink should be displayed in row 2. In row 3, field a=3, so the area needs to be blank etc.
I can't see how I can assign a variable to a particular row using $xt->assign('variable_name', 'Something'); in the BeforeProcessList event. I can't define individual variables in the list page for each possible row, there may be 1,000s of rows.
Regards
Gordon

Sergey Kornilov admin 11/4/2009

Gordon,
I guess you need to explain where exactly you want this hyperlink to appear.

D
daviesgh author 11/4/2009

Sergey,
I just want the hyperlink to appear as another column, in the row that it is relevant to. Hope this makes sense:
.......|Field A | Field B | Result

Row 1 ... 1 ....... AAA ... Text Message

Row 2 ... 2 ....... XXX ... Hyperlink ?row=2

Row 3 ... 3 ....... WWW ...

Row 4 ... 2 ....... XXX ... Hyperlink ?row=4

etc
Regards
Gordon

J
Jane 11/5/2009

Gordon,
use List page: After record processed event for this purpose:

http://www.xlinesoft.com/phprunner/docs/after_record_processed.htm

Here is a sample:

global $recno;

if ($data["Field A"]==1)

$record["Result_value"] = "Text Message";

if ($data["Field A"]==2)

$record["Result_value"] = "<a href=\"Hyperlink?row=".$recno."\">Link</a>";

if ($data["Field A"]==3)

$record["Result_value"] = "";
D
daviesgh author 11/5/2009

Thanks Jane
Gordon