Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 01-05-2011, 02:11 PM
RonHiler RonHiler is offline
 
Join Date: Mar 2005
Posts: 6
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Custom code in Standard_Redirect template

Hey guys, I hope this is the right place.

Many years ago I customized my Standard_Redirect to pull a random quote from another template file and display it whenever the redirect page came up. This worked great. And it was only like 8 or 10 lines of code, not a huge change.

Yesterday, I upgraded my board from 3.7 to 4.1, and during the process, it had marked that template as conflicting. Not surprising. It wasn't immediately obvious how to keep my modification with the changes made to the default template. Since I was in a hurry to get my board back up and running, I told it to go back to the default template, figuring I could pull up the template history later on to put my modification back in when I had a bit more time to look at it.

Well, as it turns out, you can only get a template history if the template is already customized. Since I went back to the default, there is no history to go back to. Oops.

I am definitely not a php guru (although I am a C++ programmer). I'd like to recreate that code, but I'm not really sure how to go about it. The quotes live in a phrase file called "randomquotequote", the contents of which are very simple:

Code:
<SCRIPT LANGUAGE="JAVASCRIPT">
<!--
var r_text = new Array ();
var a_text= new Array ();
r_text[0] = "A quote";
a_text[0] = "The Author";
...and so forth...
r_text[16] = "The last quote.";
a_text[16] = "The Author";

var i = Math.floor(17*Math.random());

document.write(r_text[i]);
document.write("<BR>");
document.write(a_text[i]);

//-->
</SCRIPT>
What I had added in the Standard_Redirect template was to simply access this file to grab a random quote and display it (in a box, just above the redirect box). But now I don't remember how to do that, or even really where to put it.

Can someone with a bit more PHP knowledge than me give me a nudge in the right direction?

--------------- Added [DATE]1294246356[/DATE] at [TIME]1294246356[/TIME] ---------------

Okay, I think I got it. The most intimidating part was figuring out how to access that phrase file, the rest is just formatting. Once I got that, it was pretty simple. I don't know if this is breaking any rules, but it seems to work. I just added this code to the top of Standard_Redirect (just after the <body> tag)

Code:
<!-- my custom change -->
<BR><BR><BR>
<div class="standard_error">
	<form class="block vbform" method="post" action="{vb:raw formfile}" name="postvarform">
		<h2 class="blockhead">Today's Quote</h2>
		<div class="blockbody formcontrols">
                          {vb:rawphrase randomquotequote}
		</div>
	</form>
</div>
<!-- end custom change -->
Let me know if there is anything I ought to change to make it "safer" in terms of the VBulletin code. Of course, I guess this change has to be made to each style individually (is there any way to change a template across all styles at once?).

BTW, anyone is welcome to use this or similar code if they want random quotes to appear on their redirect page. It's kind of a popular secondary feature on my board
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 11:21 PM.


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.04579 seconds
  • Memory Usage 2,204KB
  • Queries Executed 11 (?)
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
  • (2)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)showthread_list
  • (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_threadedmode.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids_threaded
  • showthread_threaded_construct_link
  • 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