vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Automatic Template Edits (https://vborg.vbsupport.ru/showthread.php?t=258536)

TheInsaneManiac 02-08-2011 03:45 AM

Automatic Template Edits
 
I am trying to get:
{vb:raw affiliation}

To display my affiliation template within the forumhome template, but I am having no luck. It doesn't display anything when I place {vb:raw affiliation} in my FORUMHOME template.

hook - global_start
Code:

$templater = vB_Template::Create('affiliation');
vB_Template:reRegister('FORUMHOME',array('affiliation' => $affiliation));
$affiliation .= $templater->render();


Andreas 02-08-2011 04:41 AM

PHP Code:

$templater vB_Template::create('affiliation');
vB_Template:preRegister('FORUMHOME', array('affiliation' => $templater->render())); 


TheInsaneManiac 02-08-2011 05:12 AM

I get a server error when using that code.

Lynne 02-08-2011 04:39 PM

You need to create and render a template and then preregister that variable for use in another template.

PHP Code:

$templater vB_Template::Create('affiliation');
// register any variables for use in your affiliation template here
$affiliation .= $templater->render();

vB_Template::preRegister('FORUMHOME',array('affiliation' => $affiliation)); 

Now use {vb:raw affiliation} in your FORUMHOME template.

Also, if you look up the hook global_start in the files, you'll see this:
PHP Code:

// Deprecated as of release 4.0.2, replaced by global_bootstrap_init_start
($hook vBulletinHook::fetch_hook('global_start')) ? eval($hook) : false

It's been deprecated for about a year now.

TheInsaneManiac 02-09-2011 10:17 PM

I used global_start with no problems, but as soon as I add your code, I get server errors. It works no problem before the code was added. Hooks work fine, but I would like to be able to place it anywhere in the forumhome. As soon as I add your code in place of mine, I get server errors.

Code:

                        $templater = vB_Template::create('affiliation');
                        $template_hook[forumhome_wgo_pos5] .= $templater->render();


Lynne 02-09-2011 11:17 PM

You can't add exactly my code since I didn't input any variables to register in your template. Also, we can't help with errors if you don't tell us exactly what error you are getting. It would also help to actually see the affiliation template code.

Also, I accidentally wrote "reRegister" instead of "preRegister" in mine above which I have since fixed.
Also, <center> tags still work these days also, but they are deprecated. One of these days they will stop working, just as the global_start hook location will stop working. I've always figured it's best to fix that now, rather than when it gets broken, but that is your call.What is the code you posted for?

TheInsaneManiac 02-09-2011 11:40 PM

What variables, this is what I don't understand. I don't have any variables. I simply just want the affiliation code to display in forumhome.

If global_start and center are going to be gone soon, what will be their replacing counterparts? Everyone uses <center> I don't know why it would be depreciated...

Boofo 02-09-2011 11:43 PM

Quote:

Originally Posted by Andreas (Post 2160074)
PHP Code:

$templater vB_Template::create('affiliation');
vB_Template:preRegister('FORUMHOME', array('affiliation' => $templater->render())); 


I've never seen it done like this before. Does this actually work?

TheInsaneManiac 02-09-2011 11:51 PM

Quote:

Originally Posted by Boofo (Post 2160776)
I've never seen it done like this before. Does this actually work?

No... apparently there are some variables that I don't know about, because it is still not working.

Boofo 02-09-2011 11:54 PM

What hook are you using to call the template from?


All times are GMT. The time now is 08:08 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.01030 seconds
  • Memory Usage 1,747KB
  • 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_code_printable
  • (4)bbcode_php_printable
  • (2)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