![]() |
A little confused now (calling a template)
Just got vBulletin 4.0.0 Suite set up on my test site for now, trying to get all of my modifications working before I install it on my live site. So, for those of you who have already had the time to play around with vB 4, how do you call templates now.
I USED to do it like in this thread by using the method below PHP Code:
So, anyone know how to call a template via a plugin now? haha (vBulletin 4.0.0 is definately a lot more confusing than I thought it'd be) |
First, you need to register the variables you will be using in the template and then you need to render it.
Example from one of mine using a template_hook: PHP Code:
PHP Code:
PHP Code:
|
Hey, thank you for your reply.
Can you please be more specific? What shout i put instead of a_variable, $tagforms, $template_hook['some_hook'], etc? What should be the hook location? |
Quote:
Code:
<img src="{vb:stylevar imgdir_misc}/paperclip.png" class="inlineimg" /> Code:
{vb:raw template_hook.postbit_signature_end} |
a_variable is the name of the variable you are registering. $tagforms was supposed to be $a_variable, but I forgot to change it - it is now changed. As for the $template_hook, that would be the name of the template_hook you are trying to use.... if you are using a template_hook. I gave several examples up there - you would not use them all for one template call.
|
How about if the hook you want does not exist. In vb3 say for instance after navbar you could print a blook right about the forumbits below the navbar. There is no such hook in vb4
http://www.vbulletin.com/forum/showt...on-for-plugins |
Then either add your own hook or modify the template manually.
|
Are there tutorials on adding your own hook location?
--------------- Added [DATE]1258332480[/DATE] at [TIME]1258332480[/TIME] --------------- Nevermind got it but still would have not liked to hard code something into forumhome if I did not have to ;) |
I think I just responded to a thread you made on vb.com. Until they add a hook under the navbar on FORUMHOME, you can just do a str_replace on <div id="pagetitle">
|
yeah you did I tried the str_replace and it did not work I asked if you knew why it did not.
|
Quote:
|
Quote:
PHP Code:
|
well your plugin would hook where ever you wish and to access the variable in the header template it would be something like this
{vb:raw random_number} --------------- Added [DATE]1258370775[/DATE] at [TIME]1258370775[/TIME] --------------- Lynne thanks I posted there because its a huge design flaw in the new system IMO. I added my own hook name and it works fine but using the str_replace or something is needed I think because the whole point of the plugin system is to NOT make hand edits to files templates etc. anyway here is the code I posted using etc Template question for plugins. Now say for instance I want to show a block of info on forumhome. I know I can do this since the template_hook is now a super global. Code:
$templater = vB_Template::create('forumhome_addon'); Code:
|
Quote:
Furthermore, while providing more information, in the following example: PHP Code:
|
Quote:
|
Well if you can no longer display a block before the forumbits because you can not longer do a str_replace and there is not a hook for there its a design flaw. I do not beleive the point of vb4 was to go backwards from vb3 in the plugin system. if vb is going to make the only way you can include a template is through the hook system since its a superglobal then they need to do hooks everywhere. The whole purpose of the plugin system is to keep you from having to hack vb files templates.
i did what I needed to do by creating a new template hook name and editing the forumhome template to include the template hook where i wanted it. Remember in vb3 how alot of hacks appeared right before the forumbits or right after. there are no hook locations in forumhome other than in who's online. In vb3 you just did a str_replace to print your template right after the navbar. So if you can not longer do a str_replace and have to use a hook instead and there are non then its a design flaw especially somewhere as prized a location as the top of bottom of the forumbits. Just my Opinion ;) --------------- Added [DATE]1258376073[/DATE] at [TIME]1258376073[/TIME] --------------- Pitman You need to register any variables for use in a template. The initial post in this thread by lynne gives examples ;) |
I think there's now a way to preRegister the variables, so as i understood it, you'll need no more str_replace ;)
I hope realy that there will be some great articles for vB4. The best way would be, if some vbulletin developers would write articles, because they could show "us" the best way to extend vB4 |
Quote:
For example, if i want to use the template_hook method, and my template name is abc, my var name is var, and i want to use it in the forumhome template, the code should be something like this? PHP Code:
|
@Yellow Slider:
If I understand correctly, you want to evaluate the template "abc" and make the result available in the FORUMHOME template via the variable "var" ? |
Quote:
|
Quote:
PHP Code:
Let me know how it goes. |
Quote:
Parse error: syntax error, unexpected ':' in public_html/forum/global.php(28) : eval()'d code on line 3 |
Quote:
PHP Code:
|
Quote:
--------------- Added [DATE]1258383869[/DATE] at [TIME]1258383869[/TIME] --------------- Quote:
|
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. ;) |
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. |
Quote:
|
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 |
Quote:
Anyway, I don't think your search/replace is correct. You wrote: PHP Code:
PHP Code:
|
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. ;)
|
Really? Strange, because I have something almost exactly like that in a plugin and it works just fine:
PHP Code:
PHP Code:
PHP Code:
|
yeah it does not like this line
Code:
This is what I have blank white page. I am following the guides here Code:
$thistemplater .= $templater->render(); |
Quote:
Try PHP Code:
HTML Code:
This is <span style=\"font-weight: bold\">bold</span> On the other hand: PHP Code:
--------------- Added [DATE]1258452044[/DATE] at [TIME]1258452044[/TIME] --------------- Quote:
--------------- Added [DATE]1258452277[/DATE] at [TIME]1258452277[/TIME] --------------- Quote:
Please post the complete code you are using. |
If you dont know the scope of the entire discussion please do not be rude with comments like that.
Code:
$output = "This is <span style=\"font-weight: bold\">bold</span>"; I have what I am doing done. This line is not liked is posted. I simply ended up creating a new hook location. Code:
$thistemplater .= $templater->render(); |
Quote:
Quote:
|
All times are GMT. The time now is 03:28 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 | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|