vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Adding a hook for some easily changable text (https://vborg.vbsupport.ru/showthread.php?t=249431)

Panzer Max 08-27-2010 01:05 PM

Adding a hook for some easily changable text
 
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

kh99 08-27-2010 02:21 PM

You could try creating a plugin using the global_start hook with this code:

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
Code:

$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:

Code:

= 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??

.

kh99 08-29-2010 02:11 PM

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

Quote:

Originally Posted by Panzer Max (Post 2091108)
Thanks for the reply, kh.

I added
Code:

$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:

Code:

= 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.


All times are GMT. The time now is 10:29 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.01065 seconds
  • Memory Usage 1,725KB
  • 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
  • (5)bbcode_code_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete