[HOW TO] Add Random Lines of Text to Your Glacier Header

How-to's, little tricks, tutorials, code examples (snippets) and read-me's.

[HOW TO] Add Random Lines of Text to Your Glacier Header

Postby Ika » 08 Mar 2008, 23:44

Purpose: This tutorial will guide you through creating a random line of text in your Glacier Style header.

Example Use: I use this as a random quote feature by adding comments posted by users of the board.

Based on Highway of Life's Random Signature Text - viewtopic.php?p=37780#p37780

The quotes only appear for logged in users and a customizable message is available for users that are logged out.

------------
1. Create a PHP file called 'quotes.php' -- Place this file in your root forum directory with 'index.php'
Place the following code in the file:
Code: Select all
<?php

$quotes = 'Random Text 01
Random Text 02
Random Text 03
Random Text 04
Random Text 05
Random Text 06';
$split_array = explode("\n", $quotes);
$rand_keys = array_rand($split_array, 1);

header("content-type: application/x-javascript");
echo "<!--\n
document.write('{$split_array[$rand_keys]}');\n
//-->";

?>


2. Place the following code in your 'overall_header.html' -- [additional changes required for use with other styles because Glacier's functions are located in the menu and not where this tutorial is placing the quote line]
Find:
Code: Select all
         <ul class="linklist navlinks">
            <li class="icon-home"><a href="{U_INDEX}" accesskey="h">{L_INDEX}</a> <!-- BEGIN navlinks --> <strong>&#8249;</strong> <a href="{navlinks.U_VIEW_FORUM}">{navlinks.FORUM_NAME}</a><!-- END navlinks --></li>

            <li class="rightside"><a href="#" onclick="fontsizeup(); return false;" class="fontsize" title="{L_CHANGE_FONT_SIZE}">{L_CHANGE_FONT_SIZE}</a></li>

            <!-- IF U_EMAIL_TOPIC --><li class="rightside"><a href="{U_EMAIL_TOPIC}" title="{L_EMAIL_TOPIC}" class="sendemail">{L_EMAIL_TOPIC}</a></li><!-- ENDIF -->
            <!-- IF U_EMAIL_PM --><li class="rightside"><a href="{U_EMAIL_PM}" title="{L_EMAIL_PM}" class="sendemail">{L_EMAIL_PM}</a></li><!-- ENDIF -->
            <!-- IF U_PRINT_TOPIC --><li class="rightside"><a href="{U_PRINT_TOPIC}" title="{L_PRINT_TOPIC}" accesskey="p" class="print">{L_PRINT_TOPIC}</a></li><!-- ENDIF -->
            <!-- IF U_PRINT_PM --><li class="rightside"><a href="{U_PRINT_PM}" title="{L_PRINT_PM}" accesskey="p" class="print">{L_PRINT_PM}</a></li><!-- ENDIF -->
         </ul>

Place on new line after:
Code: Select all
         <ul class="linklist leftside">
            <!-- IF not S_IS_BOT and S_USER_LOGGED_IN --><li class="quotehead">Famous Quotes -- </li>
            <li><script type="text/javascript" src="quotes.php"></script></li><!-- ELSE --><li class="quotehead">Important Information from the Administrators --</li><li class="loggedout">Thank you for visiting our forum. Please login to enjoy the full features of our site.</li><!-- ENDIF -->
         </ul>


3. Open 'colours.css'
At end, add
Code: Select all
li.quotehead {
color: #105289;
font-weight: bold;
}

li.loggedout {
color: #FF0000;
}


4. Open 'common.css'
Find:
Code: Select all
ul.navlinks {
   padding-bottom: 1px;
   margin-bottom: 1px;
/*   border-bottom: 1px solid #FFFFFF;  */
   font-weight: bold;
}

Un-comment 'border-bottom' leaving the following:
Code: Select all
ul.navlinks {
   padding-bottom: 1px;
   margin-bottom: 1px;
   border-bottom: 1px solid #FFFFFF;
   font-weight: bold;
}


6. Refresh your template and theme in the ACP

--------
You can change the quotes by replacing the 'Random Text 01', etc in 'quotes.php' --- Each quote goes on a separate line. Please note certain punctuation can cause a break in the code. As an example, and apostrophe needs to have a backslash before it to prevent code breaks.

Incorrect Text:
Code: Select all
$quotes = 'It's a crazy place here.
Random Text 02
Random Text 03
Random Text 04
Random Text 05
Random Text 06';


Code: Select all
$quotes = 'It\'s a crazy place here.
Random Text 02
Random Text 03
Random Text 04
Random Text 05
Random Text 06';


For more details please refer to HoL's Random Text in Signature Topic

A demo is available here: http://www.shadowflames.us
Image
05.08.09 The Black Ice Project
Please use the forums for support requests. Review the Board Rules here.
Ika    
STG Styles Team
STG Styles Team
 
Posts: 1618
Joined: 08 Jul 2007, 09:57
Location: Charlotte, NC USA
Favorite Team: Pittsburgh Steelers
Gender: Male
phpBB Knowledge: 8


Re: [HOW TO] Add Random Lines of Text to Your Glacier Header

Postby yais » 24 Apr 2008, 13:00

thanks for the tutorial.

do you know how i can have link to a topic for the quotes.
yais
Lt. Jr Grade
Lt. Jr Grade
 
Posts: 129
Joined: 20 Jan 2008, 09:05
Gender: Male
phpBB Knowledge: 3

Re: [HOW TO] Add Random Lines of Text to Your Glacier Header

Postby Ika » 24 Apr 2008, 17:24

yais wrote:thanks for the tutorial.

do you know how i can have link to a topic for the quotes.


Do you mean a topic that shows all the quotes in the php file?

If so, it is not possible that i know of as it might be a security issue.

Edit: I saw your PM, lets keep discussion in here. ---The quotes.php file will pull a random text on every page load. I for instance placed the code in my header so it appeared on every page.
Image
05.08.09 The Black Ice Project
Please use the forums for support requests. Review the Board Rules here.
Ika    
STG Styles Team
STG Styles Team
 
Posts: 1618
Joined: 08 Jul 2007, 09:57
Location: Charlotte, NC USA
Favorite Team: Pittsburgh Steelers
Gender: Male
phpBB Knowledge: 8

Re: [HOW TO] Add Random Lines of Text to Your Glacier Header

Postby yais » 02 May 2008, 10:19

sorry about pm.

I mean having the random quotes link to a certai topic.

i.e. one line saying "Read the Rules!" will link to the rules topic.
yais
Lt. Jr Grade
Lt. Jr Grade
 
Posts: 129
Joined: 20 Jan 2008, 09:05
Gender: Male
phpBB Knowledge: 3

Re: [HOW TO] Add Random Lines of Text to Your Glacier Header

Postby c4gamerz » 08 Jul 2008, 00:52

can someone please tell me how to add random lines of text in bf_vista_static style?

Thanks
c4gamerz    
Cadet IV
Cadet IV
 
Posts: 53
Joined: 09 Apr 2007, 07:48
Location: Pakistan
Gender: Male
phpBB Knowledge: 10

Re: [HOW TO] Add Random Lines of Text to Your Glacier Header

Postby tzar » 19 Jan 2010, 10:59

How this work on subsilver2 ?
tzar    
Cadet I
Cadet I
 
Posts: 12
Joined: 06 Nov 2008, 18:09
Gender: Male
phpBB Knowledge: 1

Re: [HOW TO] Add Random Lines of Text to Your Glacier Header

Postby tzar » 20 Jan 2010, 10:58

Does anyone know ?
tzar    
Cadet I
Cadet I
 
Posts: 12
Joined: 06 Nov 2008, 18:09
Gender: Male
phpBB Knowledge: 1

Re: [HOW TO] Add Random Lines of Text to Your Glacier Header

Postby tzar » 28 Jan 2010, 16:14

No one :(
tzar    
Cadet I
Cadet I
 
Posts: 12
Joined: 06 Nov 2008, 18:09
Gender: Male
phpBB Knowledge: 1

Re: [HOW TO] Add Random Lines of Text to Your Glacier Header

Postby Sniper_E » 28 Jan 2010, 22:24

Sure, exactly where would you want this to show up in your subsilver2 type style?
An image showing where you want it would help.
Would you have an image of this installed in Glacier also.

I haven't looked, but wouldn't this be shown how in Highway's topic? Check that link in the first post.
Image
No is NEVER an Option and NEVER is the only Option when it comes to Giving Up!
User avatar
Sniper_E    
STG Jedi Master
STG Jedi Master
 
Posts: 6983
Joined: 31 May 2006, 06:29
Location: Shreveport, LA
Favorite Team: The STG Team
Gender: Male
phpBB Knowledge: 6

Re: [HOW TO] Add Random Lines of Text to Your Glacier Header

Postby reality » 17 Jun 2010, 07:55

I did everything exactly as you said, but most of the cases the text will not appear. Sometimes it shows me last line - "Random Text 06". I'm able to see different lines in Firebug, but they won't show up on the screen. But why?

I've also tried changing number of lines in array to any other number (for instance 5 or 6), but then I get error: "Illegal offset type in quotes.php on line 14".
reality
Crewman
Crewman
 
Posts: 2
Joined: 16 Jun 2010, 04:59
Gender: Male
phpBB Knowledge: 4

Next

Return to Tutorials and How-Tos

Who is online

Users browsing this forum: No registered users and 6 guests