vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   append after <head> in all templates? (https://vborg.vbsupport.ru/showthread.php?t=322356)

Dr.CustUmz 04-13-2016 06:25 PM

append after <head> in all templates?
 
This turned out to be a global replace that is very handy if you know how to use it, you can find the solution begining in post 18(for vb4) and 20 (for vb3)

So I know if I was going to add something after <head> to one template I could do it something like:
Code:

$find = '<head>';
$add = '<something>';
$vbulletin->templatecache['FORUMHOME'] = str_replace($find,$find.$add,$vbulletin->templatecache['FORUMHOME']);

but how would I go about doing this to every page, since <head> is contained in templates, and not in the headinclude it makes what I'm trying to do a little more complicated.

Tried this and a few other combinations with no luck:
Code:

$find = '<head>';
$add = '<something>';
$find = str_replace($find,$find.$add,$find);


squidsk 04-14-2016 12:11 AM

Why not just add it with a template hook. There are a couple in head or its sub templates.

Dr.CustUmz 04-14-2016 11:40 AM

because im trying to change <head> to lol, just learning experiance

Dave 04-14-2016 11:43 AM

What exactly are you trying to add to <head>? Maybe there's another way to do it instead of replacing it.

MarkFL 04-14-2016 11:44 AM

If I recall correctly, what I have done in vB 3.8.9 to add something to pages is append it to either $spacer_open or $spacer_close. :)

Dr.CustUmz 04-14-2016 11:53 AM

Quote:

Originally Posted by MarkFL (Post 2568938)
If I recall correctly, what I have done in vB 3.8.9 to add something to pages is append it to either $spacer_open or $spacer_close. :)

$spacer_open consists of I believe 3 divs and first appears in the header template which is not the <head> tag,

this is just an example not what I'm doing, but say I wanted to replace
Code:

<head>
with
Code:

<head class="someClass">
<head> is not located in the headinclude template which IMO is where it should be, but instead pretty much every main template has its own <head> tag.

so its looking like if I want to do something like this I'll have to create a replace for every template

Code:

$find = '<head>';
$replace = '<head class="someClass">';
$vbulletin->templatecache['FORUMHOME'] = str_replace($find,$replace,$vbulletin->templatecache['FORUMHOME']);
$vbulletin->templatecache['showthread'] = str_replace($find,$replace,$vbulletin->templatecache['showthread']);
etc...


MarkFL 04-14-2016 12:01 PM

What do you get by adding CSS to the head element?

Dr.CustUmz 04-14-2016 12:04 PM

that is not what im doing was just an example lol

Dave 04-14-2016 12:07 PM

If it really turns out to be difficult to do this, you can write some native JavaScript to do this.
http://stackoverflow.com/questions/2...o-the-head-tag

Dr.CustUmz 04-14-2016 12:23 PM

the end result will actually be for spiders, and i dont believe spiders see execute js

--------------- Added [DATE]1460644385[/DATE] at [TIME]1460644385[/TIME] ---------------

why does this method not work?

Code:

<head> = str_replace('head', 'head class="test"', <head>);


All times are GMT. The time now is 03:55 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01102 seconds
  • Memory Usage 1,737KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (6)bbcode_code_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete