PDA

View Full Version : eval $vbulletin->templatecache not working!


al3bed
08-25-2009, 01:52 PM
hi,

I have a problem but I don't know where exactly?

look at the code please

$ain_adsense_info = $vbulletin->db->query_read("
SELECT id, type, content, channel, slot, width, height
FROM " . TABLE_PREFIX . "ainadsense AS ainadsense
ORDER BY id ASC
");

while ($ainadsense = $db->fetch_array($ain_adsense_info))
{
exec_switch_bg();
eval('$ain_adsense_bit .= "' . $vbulletin->templatecache['ain_adsense_manager_bit'] . '";');
}


the template 'ain_adsense_manager_bit' will take data and show it in home template
but my problem is that $ain_adsense_bit not working inside any template!

and the table is not empty

Lynne
08-25-2009, 02:41 PM
Variables get called in different ways depending on the hook location. Find your hook in the code. Look at the code above it to see how the variables are being called. You may not using the correct variable syntax.

al3bed
08-25-2009, 04:21 PM
i use misc_start hook .. it's look like:

if ($_REQUEST['do'] == 'mypage') {

/* my code here */

}

so if i enter: misc.php?do=mypage it's will show my code

my code is like forumbit code but not working

i mean only the part of the loop:
eval('$ain_adsense_bit .= "' . $vbulletin->templatecache['ain_adsense_manager_bit'] . '";');

Lynne
08-25-2009, 05:29 PM
That isn't normally the way you would eval a template.

eval('$ain_adsense_bit .= "' . fetch_template('template_name_here') . '";');

al3bed
08-25-2009, 05:46 PM
what is your way?

Lynne
08-25-2009, 06:01 PM
I posted it.

al3bed
08-25-2009, 08:33 PM
oh sorry i don't notice that ..

fetch_template work great .. thanks

but why $vbulletin->templatecache not working for me .. it's work before!

Lynne
08-25-2009, 08:51 PM
I've only ever used $vbulletin->templatecache to access a template that is cached and do something like a str_replace in it. I don't know how you have used it before, so I can't comment on why it worked before and not now.