Find a single element in a Smarty array [solved]
Posted: Sun Nov 13, 2011 2:51 pm
In the Add/Edit an Event form, the CGCalendar module loops over the $categories array like this:
I am trying to work with just one of the category names - I want to be able to access each category name directly, without a loop, and to understand how to access that. I've tried the following (and at least the same number of other variations) with no success (no output). I don't think the first element is null or blank, because the array above throws out 'General' as the first result.
I need to stop bashing my head against the wall now... all of the documentation is good at explaining how to loop over an array, not how to access an individual element.
Code: Select all
{foreach from=$categories item='category'}
<div class="row">
<p class="row_prompt">{$category->name}:</p>
<p class="row_input">
{$category->field}
</p>
</div>
{/foreach}
Code: Select all
{$categories->name.0}
{$categories->name[0]}
{$categories.0->name}
{$categories[0]->name}
{$categories->name}
{$categories[$name.0]}
{$categories[$name].0}
{$categories.0.$name}
{$categories.name.0}