RonHiler
01-05-2011, 02:11 PM
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:
<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 1294246356 at 1294246356 ---------------
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)
<!-- 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 :)
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:
<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 1294246356 at 1294246356 ---------------
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)
<!-- 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 :)