Re: [SMARTY] accessing an array var with a variable name

Jens Kleikamp <[email protected]>
Newsgroups gmane.comp.php.smarty.general
Organization codes & concepts
Message-ID <[email protected]>
Kathleen Krause-Thompson wrote:
> Thank you for help provided in the past.
> 
> This time, I am using the section tag and would like to access an array using the $smarty.section.name.index variable (see the ??? below).
> 
> --------------------------------
> 
> {section name=ill start=1 loop=$num+1 step=1}
> 
> <p>Job Title {$smarty.section.ill.index}
> 
> {if !empty($errors.budget?????.baseSalAmt)}<span id="errortext">{$errors.budget?????.baseSalAmt}</span>{/if}
> 
> {/section}
> 
> ----------------------------
> 
>  ?????? is where I would like for the $smarty.section.ill.index to go, for example {$errors.budget2.baseSalAmt}. How would I access this array variable dynamically?
> 

Iám not sure, but this could work:

{section name=ill start=1 loop=$num+1 step=1}

  <p>Job Title {$smarty.section.ill.index}

{if !empty($errors.budget?????.baseSalAmt)}
{assign var="index" value=budget`$smarty.section.ill.index`}
<span id="errortext">{$errors.$index.baseSalAmt}</span>
{/if}

{/section}

-- 
Smarty General Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.