Hi everyone, i wonder if you might be able to help me please?
I have been trying to create a hook to choose 3 random banners and then display them through the ‘smarty template’. Nothing seems to work!!
I started with code for the first banner and all worked fine, then i added the 2 other queries to the hook file and 2 pieces of code to the template to display the results… I found each of the queries in the hook file are now being run 3 times each. It is definately something to do with the smarty template code as each query only runs once when only 1 code in template. it makes no sense!!
hook file:
[php]$headerbanner = $db->fetchRow('SELECT * FROM banner_ads WHERE … ')
$centerbanner = $db->fetchRow('SELECT * FROM banner_ads WHERE … ')
$rightbanner = $db->fetchRow('SELECT * FROM banner_ads WHERE … ')
$tpl->assign(‘banner’, $headerbanner);
$tpl->assign(‘banner’, $centerbanner);
$tpl->assign(‘banner’, $rightbanner);[/php]
smarty template code:
[php]
[/php]
i really cannot see anything wrong with any code and it works fine with just 1 code in the template!!
i found another way round this too but cannot get it too work…
instead of assigning 3 objects to the template i could just use 1 then sort it from the template… only problem i canot find how to get $object1, $object2, $object3 into 1 ojbect
any help will be greatly appreciated. Thanks