Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 08-27-2010, 01:05 PM
Panzer Max's Avatar
Panzer Max Panzer Max is offline
 
Join Date: May 2006
Posts: 196
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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
Reply With Quote
  #2  
Old 08-27-2010, 02:21 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #3  
Old 08-29-2010, 01:42 PM
Panzer Max's Avatar
Panzer Max Panzer Max is offline
 
Join Date: May 2006
Posts: 196
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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

.
Reply With Quote
  #4  
Old 08-29-2010, 02:11 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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".
Reply With Quote
  #5  
Old 08-29-2010, 05:48 PM
BirdOPrey5's Avatar
BirdOPrey5 BirdOPrey5 is offline
Senior Member
 
Join Date: Jun 2008
Location: New York
Posts: 10,610
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Panzer Max View Post
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.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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.03783 seconds
  • Memory Usage 2,203KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (5)bbcode_code
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (5)post_thanks_box
  • (5)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (5)post_thanks_postbit_info
  • (5)postbit
  • (5)postbit_onlinestatus
  • (5)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete