rossco_2005
12-12-2009, 04:35 PM
I have an array:
$binaries = array(
0 => array(
'subject' => 'Subject 1',
'binaryid' => 1,
'groups' => array('alt.binaries.teevee', 'alt.binaries.multimedia')
),
1 => array(
'subject' => 'Subject 2',
'binaryid' => 2,
'groups' => array('alt.binaries.xvid')
),
);
I then render a template:
$templater = vB_Template::create('ng_managebinaries');
$templater->register_page_templates();
$templater->register('navbar', $navbar);
$templater->register('binaries', $binaries);
print_output($templater->render());
In my template I can use this code fine:
<vb:each from="binaries" value="binary">
{vb:raw binary.subject}
{vb:raw binary.binaryid}
</vb:each>
But this template code would give me an error:
<vb:each from="binaries" value="binary">
{vb:raw binary.subject}
{vb:raw binary.binaryid}
<vb:each from="binary.groups" value="group">
{vb:raw group}
</vb:each>
</vb:each>
The error that I get is:
Warning: Invalid argument supplied for foreach() in D:\Sites\vbdev\includes\class_core.php(3917) : eval()'d code on line 142
Does anybody know what would be the correct syntax to use for this (from="binary.groups" is probably incorrect)? Or have I found a vBulletin bug?
--------------- Added 1260659509 at 1260659509 ---------------
I figured this out.
I must use this:
<vb:each from="binaries" value="binary">
{vb:raw binary.subject}
{vb:raw binary.binaryid}
<vb:each from="binary['groups']" value="group">
{vb:raw group}
</vb:each>
</vb:each>
(from="binary['groups']" instead of from="binary.groups")
Just incase anyone is wondering, or searching for the same answer.
Thanks to whoever looked.
--------------- Added 1260659823 at 1260659823 ---------------
That info also comes in handy if you're trying to use any arrays inside of a curly bracket.
For example:
{vb:rawphrase {vb:raw item['phrase']}}
$binaries = array(
0 => array(
'subject' => 'Subject 1',
'binaryid' => 1,
'groups' => array('alt.binaries.teevee', 'alt.binaries.multimedia')
),
1 => array(
'subject' => 'Subject 2',
'binaryid' => 2,
'groups' => array('alt.binaries.xvid')
),
);
I then render a template:
$templater = vB_Template::create('ng_managebinaries');
$templater->register_page_templates();
$templater->register('navbar', $navbar);
$templater->register('binaries', $binaries);
print_output($templater->render());
In my template I can use this code fine:
<vb:each from="binaries" value="binary">
{vb:raw binary.subject}
{vb:raw binary.binaryid}
</vb:each>
But this template code would give me an error:
<vb:each from="binaries" value="binary">
{vb:raw binary.subject}
{vb:raw binary.binaryid}
<vb:each from="binary.groups" value="group">
{vb:raw group}
</vb:each>
</vb:each>
The error that I get is:
Warning: Invalid argument supplied for foreach() in D:\Sites\vbdev\includes\class_core.php(3917) : eval()'d code on line 142
Does anybody know what would be the correct syntax to use for this (from="binary.groups" is probably incorrect)? Or have I found a vBulletin bug?
--------------- Added 1260659509 at 1260659509 ---------------
I figured this out.
I must use this:
<vb:each from="binaries" value="binary">
{vb:raw binary.subject}
{vb:raw binary.binaryid}
<vb:each from="binary['groups']" value="group">
{vb:raw group}
</vb:each>
</vb:each>
(from="binary['groups']" instead of from="binary.groups")
Just incase anyone is wondering, or searching for the same answer.
Thanks to whoever looked.
--------------- Added 1260659823 at 1260659823 ---------------
That info also comes in handy if you're trying to use any arrays inside of a curly bracket.
For example:
{vb:rawphrase {vb:raw item['phrase']}}