You are here: Dynamic Variables « Smarty Templates Posts « IT news, forums, messages
Dynamic Variables

Posted by "Stephen J. Lawrence Jr." on 09/30/24 11:17

Hello, I have a section of template code that needs to be repeated for
each value in an array. I would like the variables used in the loop to
dynamically change for each iteration. Here is an example of the old code:

<tr>

<td style="text-align: center;">1</td>

<td style="text-align: center;">

<select name="page_key_1_type">

<option value="NULL" >None</option>

<option value="NULL" >------</option>

{foreach from=$command_types item=command_type}

{if $command_type eq $page_obj->page_key_1_type}

{assign var="selected" value="SELECTED"}

{/if}

<option value="{$command_type}" {$selected}>{$command_type}</option>

{assign var="selected" value=""}

{/foreach}

</select>

</td>

<td style="text-align: center;">

<input name="page_key_1_value" value="{$page_obj->page_key_1_value}" size="10" />

</td>

</tr>

Essentially, what I want to do is have an array like this
('1','2','3','4','5','aab','ccd') used to draw this row to the screen,
and each iteration would change the '1' in the above example with
whichever array value the loop was on. For example:

the line that reads "{if $command_type eq $page_obj->page_key_1_type}"
would be {if $command_type eq $page_obj->page_key_2_type} on the second
iteration, etc,etc.. I need to be able to make the
$page_obj->page_key_THISISDYNAMIC_type change each iteration.

Any ideas?

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация