1
mqualls
Accessing PHP variables from template? How to?
  • 2004/7/22 13:44

  • mqualls

  • Just popping in

  • Posts: 2

  • Since: 2004/7/22


According to this page on Smarty's Web site:

PHP Variables in Smarty Templates

You should be able to access a PHP variable from the template...However, I am having a rough go of it...

This is what I have put in the "mylinks_topten.html" template:

<{if $rate == 1}>
<img src="<{$xoops_url}>/modules/mylinks/images/chlulinkstop.jpg" border="0" alt="Top Rated Links" /></a>
<{else}>
<img src="<{$xoops_url}>/modules/mylinks/images/chlulinkspop.jpg" border="0" alt="Most Popular Links" /></a>
<{/if}>

It, as you might guess, is executing the else clause every time....Any ideas on what I am doing wrong? Do I need to make some sort of explicit reference to the PHP variable in order to access the value from the template? Thanks!

2
dheltzel
Re: Accessing PHP variables from template? How to?
  • 2004/7/22 15:13

  • dheltzel

  • Not too shy to talk

  • Posts: 164

  • Since: 2003/1/8 1


Put this line in the .php file to make the variable visible to Smarty:

$xoopsTpl->assign('rate', '1');

Also, you might try using 'eq' instead of '==' like this:

<{if $rate eq '1'}>

Dennis

3
mqualls
Re: Accessing PHP variables from template? How to?
  • 2004/7/22 15:18

  • mqualls

  • Just popping in

  • Posts: 2

  • Since: 2004/7/22


Thanks for the reply...Am now traveling down the path you suggested...Probably did not dig enough before posting my question....Thanks again!