PDA

View Full Version : Footer Template


Black Snow
11-21-2014, 02:39 PM
I am trying to do a str_replace in the footer so my edit shows up on every page but vB doesn't seem to like it. The function works fine on every page as long as it's not in the footer.

Is there a way to do this on all pages or is there a more simple way to str_replace in the footer?
Example
$vbulletin->templatecache['FORUMHOME'] = str_replace($find, $replace, $vbulletin->templatecache['FORUMHOME']);

ozzy47
11-21-2014, 02:45 PM
Well first off, you are doing the replace on th forumhome template, not the footer.

Black Snow
11-21-2014, 02:49 PM
Well first off, you are doing the replace on th forumhome template, not the footer.

I know that, I was testing out my theory that the footer template doesn't like str_replace's. It was an example to see if there is an array or something that can edit the footer template OR do a str_replace on the pages that would need it, i.e. FORUMHOME, FORUMDISPLAY, SHOWTHREAD etc.

ozzy47
11-21-2014, 03:43 PM
Well then you need to show exactly what it is you are trying to do, as providing some random example don't help to figure out what the issue is. :)

kh99
11-21-2014, 04:03 PM
What hook are you using? If you want to do a replacement on the footer in the template cache then you pretty much need to use hook parse_templates for it to always work right.

Black Snow
11-21-2014, 04:15 PM
I'm using process_templates_complete I think. Not sure as I'm on my phone at the moment.

kh99
11-21-2014, 05:12 PM
I'm using process_templates_complete I think. Not sure as I'm on my phone at the moment.

If that's true then that's the problem. The footer has already been rendered at that point. But you could probably do a replacement on $footer instead of the template cache.

Black Snow
11-21-2014, 05:56 PM
If that's true then that's the problem. The footer has already been rendered at that point. But you could probably do a replacement on $footer instead of the template cache.

How would I go about doing that?

kh99
11-21-2014, 06:00 PM
The same way you do it for the template cache, except you use $footer instead of $vbulletin->templatecache['footer']. But it's been rendered at that point so the "find" might not be the same as it is for the cache.

But that was just an option. It's probably easier to just change the hook location to parse_templates.

Black Snow
11-21-2014, 06:12 PM
OK, cool.

I have made my own hook like this using hook: process_templates_complete

global $vbulletin;

$templater = vB_Template::create('XXX');
$templater->register('XXX', $XXX);
$template_hook[new_hook] .= $templater->render();

This correct?

Muhammad Rahman
11-23-2014, 06:14 AM
OK, cool.

I have made my own hook like this using hook: process_templates_complete

global $vbulletin;

$templater = vB_Template::create('XXX');
$templater->register('XXX', $XXX);
$template_hook[new_hook] .= $templater->render();

This correct?

https://vborg.vbsupport.ru/showthread.php?t=228078