View Full Version : Adding a hook for some easily changable text
Panzer Max
08-27-2010, 01:05 PM
I need to add something to my three templates navbar where I can change the text in a file that will instantly change on the forum page. I have a fuzzy idea how to do this but I would like to get some feedback from someone who knows exactly what it takes.
For example,
phrase ="$vbphrase[text_name]" goes in the navbar page
what file do I add the text into?
I would be glad to stipend anyone who can simply describe what I need to do.
thx
You could try creating a plugin using the global_start hook with this code:
$mytext = file_get_contents("/usr/public_html/forum/info.txt");
Then use $mytext in your template.
Of course you will change "$mytext" and "/usr/public_html/forum/info.txt" to whatever you want to use.
Panzer Max
08-29-2010, 01:42 PM
Thanks for the reply, kh.
I added
$mytext = file_get_contents("/usr/public_html/forum/info.txt");
in my navbar where I wanted the text to appear, and uploaded a text file called info.txt to the forum folder, but the forum page is displaying:
= file_get_contents("/usr/public_html/forum/info.txt");
I also tried shortening the path to
"/public_html/forum/info.txt"
and also tried
"/forum/info.txt"
but the webpage just displays the bit after $mytext
Any suggestions?
Update: ah, I see, you mentioned a plug in. I have not used them much, is there a basic guide you know of I can read??
.
The manual is here: http://www.vbulletin.com/docs/html/ (remember to choose your version from the drop-down because it defaults to the latest version 4 if you don't). There's a section in the manual called "Plugin System".
However, it's pretty simple. From the admin control panel "Plugins & Products" section choose "Add New Plugin". Choose the hook location (global_start) and give it a name that makes sense to you. Then just enter the code in the box. Don't worry about the other fields.
If you want to read the manual and get more fancy you can create a product, add the plugin to your product, then you can export and import it as you like (for instance, export it so that in case you ever need to do a clean install you can just import it again).
As far as the code, the path name needs to be the actual path on your server. If you're uploading your text file to where everything else is, then you could probably use this:
$mytext = file_get_contents(CWD . "/info.txt");
(ETA: I added a '/' to the above - kh)
Of course you can choose any variable name or file name you want instead of "$mytext" or "info.txt".
BirdOPrey5
08-29-2010, 05:48 PM
Thanks for the reply, kh.
I added
$mytext = file_get_contents("/usr/public_html/forum/info.txt");
in my navbar where I wanted the text to appear, and uploaded a text file called info.txt to the forum folder, but the forum page is displaying:
= file_get_contents("/usr/public_html/forum/info.txt");
.
The main reason this isn't working is because you put it in your navbar template... Templates can't run PHP code so you need to put this in a plugin per the above instructions.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.