The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#11
|
||||
|
||||
Because "<head>" is not a string variable.
|
#12
|
||||
|
||||
hmmm, im no good with preg replaces, but shouldn't something like this work, on either global or parse templates.
this is not working Code:
$find = preg_replace("/<head[^>]>/i", "TEST", $find); |
#13
|
||||
|
||||
You don't need to use regex here with preg_replace(), but what you need is to have the template code stored as a string, and then just use str_replace() on the string.
|
#14
|
||||
|
||||
What exactly are you trying to do because the head tag does not take any attributes, so there's literally nothing you can change with the actual tag itself. The contents can be changed but as I said that's easily accomplished with template hooks.
|
#15
|
||||
|
||||
im trying to do something along the lines of (again not the code I'm actually using)
HTML Code:
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:og="http://ogp.me/ns#" xmlns:fb="http://www.facebook.com/2008/fbml">
so in the end i can replace a tag across multiple templates. so think of it this way since instead of head, everything on here says body. i want to add an onload event to all body tags, in every template, without having to say every template. so we do something like this for every template there is a body tag: Code:
$find = '<body>'; $replace = '<body onload="myFunction()">'; $vbulletin->templatecache['FORUMHOME'] = str_replace($find,$replace,$vbulletin->templatecache['FORUMHOME']); $vbulletin->templatecache['showthread'] = str_replace($find,$replace,$vbulletin->templatecache['showthread']); etc... this would be an example of it, but this doesnt work: Code:
$find = '<body>'; $replace = '<body onload="myFunction()">'; $find = str_replace($find, $replace, $find); |
#16
|
||||
|
||||
What I would do to add an onload event to the body element on all pages is in a plugin hooked to "parse_templates" with the following:
PHP Code:
|
#17
|
||||
|
||||
mark thanks for always being around to help, but I feel like I'm wasting your time =/
I was only throwing another example to what could be achieved with the end result I'm looking for. so lets look at what I'm intending on doing: In every template that has a <html> tag, i want to add some attributes. so lets say for just a one attribute example this is exactly what i want to do. across every single template: Code:
$find = '<html>'; $replace = '<html lang="en">'; $find = str_replace($find, $replace, $find); but the end result should be something like this if it's achievable. instead of doing: Code:
$find = '<html>'; $replace = '<html lang="en">'; $vbulletin->templatecache['Template1'] = str_replace($find,$replace,$vbulletin->templatecache['Template1']); $vbulletin->templatecache['Template2'] = str_replace($find,$replace,$vbulletin->templatecache['Template2']); $vbulletin->templatecache['Template3'] = str_replace($find,$replace,$vbulletin->templatecache['Template3']); $vbulletin->templatecache['Template4'] = str_replace($find,$replace,$vbulletin->templatecache['Template4']); $vbulletin->templatecache['Template5'] = str_replace($find,$replace,$vbulletin->templatecache['Template5']); $vbulletin->templatecache['Template6'] = str_replace($find,$replace,$vbulletin->templatecache['Template6']); $vbulletin->templatecache['Template7'] = str_replace($find,$replace,$vbulletin->templatecache['Template7']); etc.... |
#18
|
||||
|
||||
This works on my vB 4.2.x dev site...a plugin hooked at "parse_templates":
PHP Code:
|
#19
|
||||
|
||||
causes everything to go white with no page source lol
|
#20
|
||||
|
||||
Yeah, I got the same on my vB 3.8.9 dev site, but I thought it worth a shot since it works with vB 4.2.x.
--------------- Added [DATE]1460691040[/DATE] at [TIME]1460691040[/TIME] --------------- This works on my vB 3.8.9: PHP Code:
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|