|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
ZeroFill Smarty Rookie
Joined: 31 Aug 2003 Posts: 28
|
Posted: Tue Sep 02, 2003 12:07 am Post subject: using $smarty.section.name.index as index for an array? |
|
|
can/how do i use $smarty.section.name.index as the index value of an array?
Code: |
<{foreach from=$choices[q] item=curr_choice}>
<{include file="$qtypes[$smarty.section.q.index].tpl" choice=$curr_choice}>
<{/foreach}>
|
produces
Code: |
Fatal error: Smarty: [in user_form.tpl line 101]: syntax error: $smarty. is an unknown reference (Smarty_Compiler.class.php, line 1771)
|
putting backticks
Code: |
<{foreach from=$choices[q] item=curr_choice}>
<{include file="$qtypes[`$smarty.section.q.index`].tpl" choice=$curr_choice}>
<{/foreach}>
|
produces
Code: |
Warning: Smarty error: unable to read template resource: "Array[0].tpl"
|
q gets incremented from a section loop above. btw, my delimiters are <{ and }>
i would use [q] but all my array's are base 0
[edit]
hmm, this is interesting. i tried using q anyways and it seems to be producing the right index number. i thought q started at 1, not 0? my print_r($smarty); shows my arrays are still base 0 |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|