SUMMARY: I need to access an element in an array that is passed to a template from a module and test for it's existence.
I have a function in a module that looks like this:
function subscriptions(){
$subscriptions = array('sub1'=>array(...unimportant data...),
'sub4'=>array(...unimportant data...)
);
$data['subscriptions'] = $subscriptions;
$output = $this->EE->TMPL->parse_variables_row($this->EE->TMPL->tagdata, $data);
return $output;
}
and a template that looks like
{exp:my_module:subscriptions} {if subscriptions:sub4}User is subscribed to sub4{/if} {/exp:my_module:subscriptions}
but that doesn't seem to work. I want to display certain things based upon what subscriptions a user has. This is not just to iterate through and print out subscriptions.
I also tried
<?php if($subscriptions['sub4']){ echo 'User is subcribed to sub4' } ?>
and it says subscriptions isn't set.