vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   function to include code on templates (https://vborg.vbsupport.ru/showthread.php?t=286012)

Scanu 07-27-2012 07:38 PM

function to include code on templates
 
Hi i'm trying to make a function for editing templates this is what i make
PHP Code:

require_once(DIR '/includes/class_template_parser.php');
function 
template_include ($template_name,$code,$position) {
$parser = new vB_TemplateParser($code);
$parser->dom_doc = new vB_DomDocument($parser->fetch_dom_compatible());
if (
$position 'end'){
$include ' $final_rendered .= \' '.trim($parser->_parse_nodes($parser->dom_doc->childNodes())).'\'; ';
$vbulletin->templatecache[''.$template_name] .= $include;
} else {
$include '$final_rendered = \' '.trim($parser->_parse_nodes($parser->dom_doc->childNodes())) . '\' . ';  
$vbulletin->templatecache[''.$template_name] = substr_replace($vbulletin->templatecache[''.$template_name], $include017);
}
}
template_include('header','test','end'); 

but it doesn't work it seems that "$vbulletin->templatecache[''.$template_name] .= $include;" doesn't work in a function.. where am i wrong :S

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

The variable $vbulletin->templatecache['.....'] isn't working in a function! Why? :(

Badshah93 07-29-2012 05:43 PM

globalize $vbulletin inside a function.

PHP Code:

global $vbulletin


Sarteck 08-01-2012 09:41 AM

Also, isn't $vbulletin->templatecache[''.$template_name] the same thing as $vbulletin->templatecache[$template_name]? X3 Why prepend an empty string literal to it?

Scanu 08-01-2012 10:04 AM

That was a test, because in '' i should put prefix of template however thanks the code works $vbulletin isn't a variable declared on the function so i have to globalize it


All times are GMT. The time now is 11:51 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.01124 seconds
  • Memory Usage 1,721KB
  • 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
  • (2)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)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