vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=251)
-   -   A little confused now (calling a template) (https://vborg.vbsupport.ru/showthread.php?t=227892)

Shadab 11-16-2009 12:25 PM

Quote:

Originally Posted by Yellow Slider (Post 1915210)
Yes.

Try the code below:

PHP Code:

$abcHTML vB_Template::Create('abc')->render();

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

Then you can use {vb:raw var} in your Forumhome template to insert the evaluated html.
Let me know how it goes.

Yellow Slider 11-16-2009 12:32 PM

Quote:

Originally Posted by Shadab (Post 1915215)
Try the code below:

PHP Code:

$abcHTML vB_Template::Create('abc')->render();

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

Then you can use {vb:raw var} in your Forumhome template to insert the evaluated html.
Let me know how it goes.

I get en error:
Parse error: syntax error, unexpected ':' in public_html/forum/global.php(28) : eval()'d code on line 3

Shadab 11-16-2009 12:34 PM

Quote:

Originally Posted by Yellow Slider (Post 1915222)
I get en error:
Parse error: syntax error, unexpected ':' in public_html/forum/global.php(28) : eval()'d code on line 3

A colon was missing in line 3. Sorry. Try this:

PHP Code:

$abcHTML vB_Template::create('abc')->render();

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


Yellow Slider 11-16-2009 12:39 PM

Quote:

Originally Posted by Shadab (Post 1915224)
A colon was missing in line 3. Sorry. Try this:

PHP Code:

$abcHTML vB_Template::create('abc')->render();

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


Great, it's working, thank you :)

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

Quote:

Originally Posted by Shadab (Post 1915224)
A colon was missing in line 3. Sorry. Try this:

PHP Code:

$abcHTML vB_Template::create('abc')->render();

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


One more question, why did you add the "HTML" at the end of the variable?

Omegatron 11-16-2009 01:51 PM

Because the template example he gave the name of the template was $abcHTML thats all in his example.

Now the point I am making is I can make what I am doing work by defining a new hook works great. even pre registering values can work fine but that still means you need to hand edit the actual template you want to insert it to and place the variable there. With str_replace you never had to hand edit templates plugins where just that true plugins without having to touch the vb code. If I upgrade vb then one will have to redo there template edits which to me is a huge design flaw. If the vb developers are going to lock you into doing things a certain why then they really need to place template hooks in alot of places. ;)

Paul M 11-16-2009 02:06 PM

Since I am at work, I cannot check your assertion that str_replace() cannot be used, but even if it were true, its not a design flaw in vb4 - it was never an official plugin method, but mearly a hack that happened to work. So if anything, it was a design flaw in 3.x

Off the top of my head, I cant think why it would no longer work, but as I said, Im at work, so cant check anything.

Lynne 11-16-2009 02:11 PM

Quote:

Originally Posted by Omegatron (Post 1915268)
Because the template example he gave the name of the template was $abcHTML thats all in his example.

Now the point I am making is I can make what I am doing work by defining a new hook works great. even pre registering values can work fine but that still means you need to hand edit the actual template you want to insert it to and place the variable there. With str_replace you never had to hand edit templates plugins where just that true plugins without having to touch the vb code. If I upgrade vb then one will have to redo there template edits which to me is a huge design flaw. If the vb developers are going to lock you into doing things a certain why then they really need to place template hooks in alot of places. ;)

I think you may want to start a thread an post your code in there. In on of my mods, I preregistered variables and then used str_replace to put them in a template. So, it can be done just like before with a little bit of registering/preregistering of your variables.

Omegatron 11-16-2009 02:27 PM

I already did my friend in post 13 ;) I basically responded right to you when you asked me to post the code.

I defined one variable for use in my template as thats all that is needed but I can not get the template included where I want because there is no hook using a str_replace

Defining a new hook works great thats not an issue but I want to keep from having to hand edit vb templates in any manner.

https://vborg.vbsupport.ru/showpost....6&postcount=13

Lynne 11-16-2009 02:41 PM

Quote:

Originally Posted by Omegatron (Post 1915296)
I already did my friend in post 13 ;) I basically responded right to you when you asked me to post the code.

I defined one variable for use in my template as thats all that is needed but I can not get the template included where I want because there is no hook using a str_replace

Defining a new hook works great thats not an issue but I want to keep from having to hand edit vb templates in any manner.

https://vborg.vbsupport.ru/showpost....6&postcount=13

I was suggesting your own new thread because this one has so many users posting in it and it's hard to follow conversations.

Anyway, I don't think your search/replace is correct. You wrote:
PHP Code:

$search_text '<div id=\"pagetitle\">';
    
$vbulletin->templatecache['FORUMHOME'] = str_replace($search_text,$thistemplater.$search_text,$vbulletin->templatecache['FORUMHOME']); 

And you don't need to escape the double-quotes since you have it inside single quotes.
PHP Code:

$search_text '<div id="pagetitle">';
    
$vbulletin->templatecache['FORUMHOME'] = str_replace($search_text,$thistemplater.$search_text,$vbulletin->templatecache['FORUMHOME']); 


Omegatron 11-16-2009 05:15 PM

If I do what you say its a parse error. In all my days of PHP you need to escape quotes when you use html in a php file. ;)


All times are GMT. The time now is 12:57 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.01317 seconds
  • Memory Usage 1,767KB
  • 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
  • (7)bbcode_php_printable
  • (7)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)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