PDA

View Full Version : Issues with modifying templatecache


Raptor
06-27-2019, 08:05 PM
Hello, all.

I'm attempting to replace a string in the footer template, and I'm running into an issue.

$z_name = 'footer';

if (isset($vbulletin->templatecache[$z_name]))
{
$z_temp = $vbulletin->templatecache[$z_name];
$str_search = "injected_data";
$str_replace = "fubar_123";

// This works:
$z_temp = str_replace($str_search, $str_replace, $z_temp);
// This doesn't:
$vbulletin->templatecache[$z_name] = $z_temp;
}

$z_temp is getting set - if I echo out the contents, I get the correct content (the footer template contents with the replaced string). However, setting the templatecache at the end is not working: it is not set to the contents of $z_temp, and appears to be unchanged.

Any help would be appreciated!

MarkFL
06-28-2019, 01:41 AM
Where do you have your plugin hooked?

Raptor
06-28-2019, 04:47 AM
It's hooked to global_complete - is that too late in the process?

MarkFL
06-28-2019, 01:24 PM
I usually hook auto-template edits at "process_templates_complete". I can't say your hook is wrong per se, but give that one a try and see if you get the desired result. :)