Quote:
|
Hello everyone, I have been reading this article over and over again trying to figure out what I am doing wrong. Basically I am trying to put the contents of one template into another using a plug in. The template in question are:
-OFTW -COFTW_FAQ I want to be able to put the contents of template COFTW_FAQ into a variable that I can then use in OFTW template. I am using a script (oftw.php) which uses the OFTW template; I need to be able to insert the contents of COFTW_FAQ into that template using a plug-in. So this is what I have so far: Plug-in 1: Hook: Global Start PHP Code:
PHP Code:
Code:
{vb:raw COFTW_FAQ} Please Help I have been hitting myself in the head for the last 4 hours! :( --------------- Added [DATE]1310166367[/DATE] at [TIME]1310166367[/TIME] --------------- UPDATE!!! After more thinking... I can see that I was a bit off, I am now using only plug in to try and accomplish what I want but still just blank... Hook Location: Process Templates Complete PHP Code:
--------------- Added [DATE]1310224935[/DATE] at [TIME]1310224935[/TIME] --------------- GOT IT!!! FINALLLLY!!!!! xD I had to just register my variable in the actual oftw.php file . Since it was a custom page the script did not have the variable registered so I added PHP Code:
|
Congrats - good to see you got it working :D
|
Quote:
global_bootstrap_init_start should be used instead of global_start in most circumstances. |
Quote:
|
If you are going to assign several variables in a row, you may want to use the quickRegister function, as it is a lot more readable and clear what is happening (IMO).
PHP Code:
|
Quote:
|
As a general rule: Use a hook that is only called where you need the variable. Normally, you execute code before registering to get the values, and you want to run that only if it's needed. Of course, using stuff like if THIS_SCRIPT will do the job, too.
|
i learned how to make custom templates like this. I have a variable that i want to be able to use on the header on every page in vbulletin. I cant get it to save my variable globaly tho. I'm only able to use this var within the template. I read the part where it talked about Save into an array and preregister to use in an existing/stock template. but could not get it to work. by the way, I have no idea how to show code on here
Code:
$eventlist = mysql_query("SELECT * FROM thread WHERE forumid = 8 ORDER BY dateline DESC", $connection); |
Quote:
[code.]your code here[./code] Would be Code:
your code here Would be PHP Code:
Would be HTML Code:
your code here |
Quote:
|
What hook is your code on?
|
what's a hook? I dont have a hook. I ended up just doing this. I basically just added my database code to the forum.php file and got it to work, but i have to modify every template like I mentioned in this thread, i'd rather use this thread https://vborg.vbsupport.ru/showthread.php?t=267120
|
Quote:
See my post in the other thread. |
First let me say that I am not PHP literate, but can find my way around 9 times out of 10.
I am creating custom templates to include my non vb scripts but am having troubles when trying to include a variable(?) from this script in any template outside the main body. I will try to be as detailed as possible, hopefully any responses will include the information I give as a real life example so that I can get an understanding of what was done. Goal: to take $companyname from the below script and add it to my page title, navbits etc. (currently I only get echos of $companyname or {vb:raw companyname}, depending on where I am in my efforts. PHP Code:
PHP Code:
PHP Code:
PHP Code:
Dave |
I don't know if it's your only problem but you didn't register $companynanme in your webhost1.php file, so it won't show in your template.
|
Could you dumb that down please?
|
Quote:
Code:
$templater = vB_Template::create('webhost-php'); Code:
$templater = vB_Template::create('webhost-php'); |
Thank you so much. As soon as I can put this paint brush down I will give it a shot.
Dave |
Code:
$search_text = '<!-- end logged-in users -->'; thank you |
This has been described around the forum several times; either search or open your own thread, this is not related to the topic of this tutorial.
|
Hello everyone, is there any way to include for example this php:
cotw_func_contest_num.php?do=sotw As a variable in a plugin, then use it in a template? I also created this thread but am also posting here to see if anyone had any further ideas we could try. Any info would be very much appreciated. Thanks for your time everyone. |
I've been driven nuts. All I want to do is output $random_number using rand(1,99999) and I'm stuck.. why have they made this insanely difficult?
|
Quote:
Code:
$random_number = rand(1,99999); Then in the template put HTML Code:
{vb:raw random_number} |
Ok been banging my head on this for quite some time now and completely ready to throw in the towel. I dont know why vB had to make things so damn difficult! It used to be really easy and straight forward to extend vB but not so much now.
I just want to pull in my custom template for adding a value to the postbit userifo part using the template hook "postbit_userinfo_right_after_posts" The variable $post[field5] is already pulled in as I can do the eval like so to test it in the plugin... Code:
if ($post['field5']) If I hard code the template instead of creating it it works fine but I want it to be properly developed and not hacked. Thanks |
Because it's filled in your PHP script, but you never registered it for use in your template, and that's why it's empty there.
The tutorial does state (in bold red ;)) that you have to register every variable and array you want to use in your custom template. Try: Code:
if ($post['field5']) |
Thank You for the reply but I guess I will have to start over at square 1 to get a better understanding of the new vB4 architechure
Ok now I made that change and it work! So even though the variable/array is a standard vB one because I made a custom template I have to register the standard variables too it seems. I thought it was just our custom variables |
Quote:
Code:
ob_start(); Code:
{vb:raw insert_simple_php} actual page http://nycjdm.com/jdmgear.php any ideas? --------------- Added [DATE]1313595423[/DATE] at [TIME]1313595423[/TIME] --------------- Quote:
I have everything working now i just need to figure out how to intergrate it's login with vb4 if anyone could point me in the right direction that would be great. |
Ok, I'm probably overlooking something, or didn't do something right, or something lol, but this is my first time trying to include a custom template within another custom template on vB 4 (it was SO much easier on vB 3 :()
Anyway, this is where I'm at so far: Plugin Hook location: process_templates_complete PHP Code:
I'm calling my sidebar template in my template usml_military_ranks (and many others) by using: Code:
{vb:raw usml_military_ranks_sidebar} In the PHP file for usml_military_ranks I have: PHP Code:
|
You might try taking this line out of the php file:
PHP Code:
you don't need this and the PreRegister, and this line might actually be registering an undefined variable. |
Quote:
|
Hi, I kinda only have a short question (before I waste another few days of my life, because I didn't wanted to ask for help lol).
My Problem is, that I would like to hook a template on {vb:raw header} (so I don't need any Template edits anymore). But all I get to work is, when I add in for example Forumhome Template {vb:raw header2} (then my template gets shown, but not if I try to use the real one). So the Question is: Is it actual possible or not (to use {vb:raw header})? The Plugin Code I am using: PHP Code:
And sorry for asking stupid Questions ;). |
Quote:
But the answer is that it probably won't work because I think if 'header' gets registered somewhere else (which it probably is, just before the template is rendered), it will override what you pre-registered. |
That's what I almost feared. So back to thinking how to get rid of the last template edit.
And thanks for the answer. |
It may not be wise to use additional templates etc. just to get rid of a template edit. It adds considerable overhead.
|
There is always 2 things to consider:
- the right way - the way people / customers and such prefer it (and thats usually no template edits :P) |
1 Attachment(s)
I have been trying to do this for days, but ended up failing all the times. I have read this entire thread twice, from page 1-14 but still couldn't figure this out.
So I'm trying to change this part of showthread: https://vborg.vbsupport.ru/attachmen...1&d=1322471332 I want to change it into my own moderation action instead of just closing the thread. I want to change the template with plug-in, but I couldn't get the right variable in which the informations about showthread quickreply are stored. On the early page of this thread, someone tried to change the footer just by accessing $footer .= "things to add"; on process_template_complete. So what variable should I be focusing on with my problem? I have already prepared a new template to replace that "checkbox", I just don't know how to access the existing template by using a plugin. Any help is appreciated.. |
Ok, I'm obviously missing something, but not sure what. I'm trying to display a variable in the header template, and what I have works just fine in the navbar. Here's what I have to display my mod in the navbar (this works):
PHP Code:
PHP Code:
|
What hook are you using? Header is rendered early, you may need a hook that is executed earlier.
|
Quote:
|
All times are GMT. The time now is 11:40 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 | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|