Loop Plugin
ExpressionEngine 1.x, ExpressionEngine 2
Back to this add-on's main page
View Other Add-ons From PutYourLightsOn
Embed variables in for loop?
Support (Resolved)
Stinkotter
|
Posted: 05 March 2012 05:25 AM |
|
|
|
Hi Ben,
Thanks for creating this simple plugin, works perfectly! I have one question.. I can’t use embed variables within the loop tags (probably because those are seen as tags and not parsed by the plugin).
Example:
{exp:for_loop start="1" end="{number}" increment="1"} <option value="{index}"{if embed:selected == "{index}"} selected{/if}>{index}</option> {/exp:for_loop}
embed:selected works fine outside the for_loop tags, but not inside.
Is there a quick workaround for this?
Thanks in advance!
|
|
|
Stinkotter
|
Posted: 05 March 2012 05:32 AM |
# 1
|
|
|
Hmm seemed to find a fix myself, but it’s not so pretty (enabling php).
<?php $selected = "{embed:selected}"; ?> {exp:for_loop start="0" end="{niet}" increment="1"} <option value="{index}"<?php if ($selected == "{index}") { echo " selected"; } ?>>{index}</option> {/exp:for_loop}
|
|
|
PutYourLightsOn
|
Posted: 05 March 2012 07:47 AM |
# 2
|
|
Developer
|
seems like an embed within a loop would be terrible for performance, does a snippet work?
|
|
|
Stinkotter
|
Posted: 05 March 2012 10:32 AM |
# 3
|
|
|
Hi Ben,
I’m not really embedding a template within the loop, just reading an embed variable, which I passed to the loop. Seems fast enough, there are no additional queries or any noticeable downgrade in time.
My mistake by the way, didn’t have the code in the first post within code tags, so some code was missing.
Guess I’ll stick with this solution (enabling php) for now.
Thanks for your reply
|
|
|
PutYourLightsOn
|
Posted: 05 March 2012 11:07 AM |
# 4
|
|
Developer
|
ah yes i see. good to hear it’s not hurting performance.
|
|
|