vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Edit template with hook? (https://vborg.vbsupport.ru/showthread.php?t=285321)

Kyojii 07-08-2012 12:24 PM

Edit template with hook?
 
I have a file I would like to include on the editprofile page. Rather than edit all of the templates and include it in every one I thought it would be easier to make a hook that appends it to all of them. However when I tried this for some reason the $headinclude variable gets replaces with only "0".


PHP Code:

if ($_REQUEST['do'] == 'editprofile'){
    
$headinclude += '<script type="text/javascript" src="/includes/bubbles.js"></script>';


PHP Code:

echo htmlspecialchars($headinclude);
echo 
'<br><br><br>';
$headinclude += '<script type="text/javascript" src="/includes/bubbles.js"></script>';
echo 
htmlspecialchars($headinclude); 

Output of above code:
Code:

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> <base href="" /><!--[if IE]></base><![endif]--> <meta name="generator" content="vBulletin 4.1.7" /> <link rel="Shortcut Icon" href="favicon.ico" type="image/x-icon" /> <meta name="keywords" content="" /> <meta name="description" content="" /> <meta property="fb:app_id" content="343071649037238" /> <meta property="og:site_name" content="" /> <meta property="og:description" content="" /> <meta property="og:url" content="" /> <meta property="og:type" content="website" /> <script type="text/javascript" src="clientscript/yui/yuiloader-dom-event/yuiloader-dom-event.js?v=417"></script> <script type="text/javascript" src="clientscript/yui/connection/connection-min.js?v=417"></script> <script type="text/javascript"> <!-- var SESSIONURL = ""; var SECURITYTOKEN = "1341753294-5bf2ad92bde7df16216e232b4783009f4c143736"; var IMGDIR_MISC = "images/misc"; var IMGDIR_BUTTON = "images/buttons"; var vb_disable_ajax = parseInt("0", 10); var SIMPLEVERSION = "417"; var BBURL = ""; var LOGGEDIN = 504 > 0 ? true : false; var THIS_SCRIPT = "profile"; var RELPATH = "profile.php?do=editprofile"; var PATHS = {forum : ""} // --> </script> <script type="text/javascript" src=""></script> <link rel="alternate" type="application/rss+xml" title="" href="" /> <link rel="stylesheet" type="text/css" href="css.php?styleid=13&amp;langid=1&amp;d=1339672467&amp;td=ltr&amp;sheet=bbcode.css,editor.css,popupmenu.css,reset-fonts.css,vbulletin.css,vbulletin-chrome.css,vbulletin-formcontrols.css," /> <!--[if lt IE 8]> <link rel="stylesheet" type="text/css" href="css.php?styleid=13&amp;langid=1&amp;d=1339672467&amp;td=ltr&amp;sheet=popupmenu-ie.css,vbulletin-ie.css,vbulletin-chrome-ie.css,vbulletin-formcontrols-ie.css,editor-ie.css" /> <![endif]-->


0


kh99 07-08-2012 12:30 PM

Try using .= in place of += .

Kyojii 07-08-2012 01:15 PM

Thanks, that worked.

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

I have another question, is there a list of what the template variables actually are? I noticed there's template hooks so I tried to use regex to add something after one of the hooks in postbit_legacy however in php it seems the variable $postbit_legacy doesn't exist.

cellarius 07-09-2012 04:54 AM

postbit_legacy is a template, why would it exist as a variable? And you don't need regex to add something to a template hook, you just use a plugin at parse_templates hook, doing
PHP Code:

$template_hook['template_hook_name'] .= "whatever"


Kyojii 07-09-2012 06:41 AM

Quote:

Originally Posted by cellarius (Post 2346269)
postbit_legacy is a template, why would it exist as a variable? And you don't need regex to add something to a template hook, you just use a plugin at parse_templates hook, doing
PHP Code:

$template_hook['template_hook_name'] .= "whatever"


Yeah, I found this out. I thought it would exist as a variable because $headinclude $header etc do.

SkyStryder 07-26-2012 06:21 PM

I was actually trying something like this. There seems to be a problem
if you need to add a vb variable like {vb:raw somedata} in the middle
of "whatever". I tried "string" . {vb:raw somedata} . "string" but that
didn't help. 8-( Hints are greatly appreciated.


Quote:

Originally Posted by cellarius (Post 2346269)
PHP Code:

$template_hook['template_hook_name'] .= "whatever"



cellarius 07-26-2012 06:25 PM

You can't use template variables in plugins. Plugins are PHP only. You need to use the PHP equivalent of the template variable.


All times are GMT. The time now is 05:31 AM.

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.01390 seconds
  • Memory Usage 1,741KB
  • 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
  • (1)bbcode_code_printable
  • (5)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete