We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Template parser problem...

Development and Programming

Cheaphotels's avatar
Cheaphotels
12 posts
15 years ago
Cheaphotels's avatar Cheaphotels

hi,

is there a way to detect whether a tag variable parsed by the template parser is a single variable entry or an array?

ex:

$myarray = array(array('mytag' => 'sample'));
$this->EE->TMPL->parse_variables($this->EE->TMPL->tagdata, $myarray);

using this i can access mytag variable in the publish page like

{mytag}

then

$myarray = array(array('mytag' => array(array('mytag1' => 1), array('mytag1' =>1))));

using this i can access the variables like

{mytag}
{mytag1}
{/mytag}

now the problem is i dont have much control over the value of $myarray. so sometimes it will return just a single variable and sometimes it will contain more and sometimes it wont exist. btw im passing a large multi dimensional array.

is there a way to detect this so that i can properly adjust the code on the template?

       
dooper3's avatar
dooper3
17 posts
15 years ago
dooper3's avatar dooper3

Can you not detect it and assign another variable to the template? i.e.:

$myarray = array(array('mytag' => array(array('mytag1' => 1), array('mytag1' =>1))));
if (is_array($myarray['mytag'])) {
  $myarray = $myarray + array('is_array', true);
} else {
  $myarray = $myarray + array('is_array', false);
}

Then you can do something like:

{if is_array}
  {mytag}
    {mytag1}
  {/mytag}
{else}
  {mytag}
{/if}

Does that help? Sorry if I missed the point a bit, but that seems to be the issue you’re talking about I think :D

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.