This topic is locked
[SOLVED]

 Post message on the list page

10/21/2011 1:59:55 PM
PHPRunner General questions
C
copper21 author

Hello,
I am trying to display a message on the list page when there are results listed. I know that it states "No records found" when there are no records, but I am looking to display a message when there are records listed on the list page. I am not looking to use the "Display message on web page" event, but but display the message in the "message" field on the list page. PHP Runner 6.0
This is what I have for no results:
$xt->assign("message","Search revealed no results");
Thanks in advance.
Brian

Sergey Kornilov admin 10/21/2011

I recommend to check this article that explains how you can add new variables to the template and assign values to them:

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

C
copper21 author 10/27/2011

Hello all...again,
I am having a hard time with this...and hoping you can help. I looked over the template page and could not make sense of it. Like I mentioned before, If the list page returns 0 results, then the $message field in on displays "no records" or whatever I need it to display. If the list page shows 1 or more records, I need the $message field to display "records found" or something like that. I have tried multiple things with no luck. The latest thing that I have tried on the List Page:Before Display
if (("records_found") > 0)

{

$xt->assign("message","Search revealed records!");

}

else

{

$xt->assign("message","Search did not reveal any records");

}
Am I heading in the wrong direction?
Thanks for your help!
Brian

C
cgphp 10/27/2011
if($xt->getvar("records_found") > 0)

{

$xt->assign("message","***Search revealed records!***");

}

else

{

$xt->assign("message","***Search did not reveal any records***");

}
C
copper21 author 10/27/2011

Cristian,
Thank you for the quick reply; unfortunately that did not work. I copied and pasted your code into List Page:Before Display in the events area and it did not work. When there are no results listed, the code works; it states "Search did not reveal any records", but when there are at least one record on the page, it does not state "Search revealed records!"
Any more suggestions?
Brian

C
cgphp 10/27/2011

The message template variable is automatically handled by PHPrunner. When records_found is greater than zero message is disabled. As workaround create a new template in the HTML code (for example {$my_message}) then enter this code in the Before display event:

if($xt->getvar("records_found") > 0)

{

$xt->assign("my_message","***Search revealed records!***");

}

else

{

$xt->assign("my_message","***Search did not reveal any records***");

}
$xt->assign("message","");


Place the {$my_message} var outside the message block.

C
copper21 author 10/27/2011

Cristian,
Thank you for your help! I better understand now.
Brian