Tinkering with the old ShopScript engine. There is a cycle on the page.

{section name=i loop=$aux_pages} //код {/section} 

Is it possible to somehow get the value of the variable i, to work with it in php code?

It turned out so far only visually to display i in the input (in the body of the cycle, respectively)

 <input type="text" value="{$smarty.section.i.index}" name="cic"> 

or can somehow extract the value of the input without sending a form with this input?

UPD: smarty version 2.6.10

  • write smarty version, 2 or 3? - teran
  • in php code, this inserts tags {php} i.e. version 2? - teran
  • @teran version 2.6.10 - sbaikov
  • You can try using get_temaplate_var() , after copying the variable somewhere a la {$ x = $ smarty.section.i.index}, but not the fact that it is extracted, because Like a bit for other purposes function - teran
  • one
    Yes, perhaps this syntax only appeared in the 3rd version. It used to be {assign var="x" value=....} or {assign "x" .... } - teran

1 answer 1

Thank you so much for food teran

He pulled out the counter with crutches, but who can come in handy.

 {section name=i loop=$aux_pages} {if ($smarty.section.i.index >=0)} {assign var="a" value=$smarty.section.i.index} {/if} {php} $id_name = $this->get_template_vars('a'); //извлекаем переменную a echo $id_name; //Тело цикла {/section}