Hey everyone,
I’m probably missing something very juvenile here, but I’m writing a plugin that passes an array to the template class’ parse_variables function that looks something like this:
- 0
- url (string)
- name (string)
- items (array)
- 0
- title (string)
- url (string)And so in my template, my tags would looks something like this:
{exp:myspecialplugin:get_entries}
The top-level URL is: {url}
{items]
Item Title: {title}
Item URL: {url}
{/items}
{/exp:myspecialplugin:get_entries}The problem with my code is that it appears the {items} URL variable is conflicting with the top-level URL variable. Am I crazy? I thought that EE’s template parser would parse outward by default and so the variable conflicts shouldn’t occur? Is there any suggested means of working around this issue without prefixing every inner array?
Thanks for any insight you can provide.
Hi Jesse,
You are right that the top level variable is being overwritten by the lower level variable.
ExpressionEngine will do this in almost all cases that I’m aware of. You’ll need to “scope” the variable with a prefix.
In case I’m totally wrong, I’m moving this over to Development and Programming where the dave Community likes to poke around. They may have some seasoned insight to help you along.
Cheers,
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.