Answer the question
In order to leave comments, you need to log in
How to pull out smarty variable in php code in a normal way?
This is the second time in my life I've come across Smarty, so my question may sound very stupid. Please guide me on the path of the bright side and suggest what to do:
In the smarti template file there is a code responsible for displaying the image:
{if $unit_list[i].photo_list.0.file}<a href="/images/catalog/{$unit_list[i].photo_list.0.file}" class="highslide" onclick="return hs.expand(this)"><img src="/images/catalog/small/{$unit_list[i].photo_list.0.file}" title="{$unit_list[i].tip_info.descr} {$unit_list[i].creater_info.descr} {$unit_list[i].descr}" alt="{$unit_list[i].tip_info.descr} {$unit_list[i].creater_info.descr} {$unit_list[i].descr}"/></a>
{else}
<img src="/images/no_photo.jpg" title="{$unit_list[i].tip_info.descr} {$unit_list[i].creater_info.descr} {$unit_list[i].descr}" alt="{$unit_list[i].tip_info.descr} {$unit_list[i].creater_info.descr} {$unit_list[i].descr}"/>
{/if}
Answer the question
In order to leave comments, you need to log in
The fact is that smart is a template engine, i.e. it is responsible for presenting (rendering) the data before returning it to the browser, and its work usually begins when the controller has already completed its work. It is for this reason that there are no direct ways to transfer something from smarty back to the code, because it is not usually needed.
And, for good, you need to adhere to this style of programming, otherwise it will turn out to be the wildest mess and it will be more and more difficult to figure out where and who changed the state, and, therefore, catching jambs and bugs, sooner or later, will become a mega-difficult task.
In general, I categorically do not recommend trying to pass something from the smarti back to the code, only if it is not a rendered template, for example, letters that are rendered before the controller completes its work. In all other cases, one-way data flow is required.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question