EllisLab text mark
Advanced Search
     
Variable Conflicts Inter-Plugin?
Posted: 14 May 2012 05:32 PM   [ Ignore ]
Avatar
Joined: 2007-03-23
56 posts

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.

- Jesse

 
Posted: 15 May 2012 01:36 PM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2005-10-18
7340 posts

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,

 Signature 

How may I help you?