Mar 23

출처: http://paradigma.pt/~vd/wlog/static.php?page=static050303-161253

I’ve added support to sphpblog for random quotes, in a text file, right bellow your blog’s name in header.

Here’s how-to:

- Create one text file named quote.txt, with a couple of lines within.
Put in any place in the sphpblog directory, we’re using themes dir.

- Open themes.php in your themes directory
(example: themes/default/themes.php)

- In the function theme_pagelayout add between:
$page_width = $content_width + $menu_width;

# Random Quote
$quoteFile = “themes/quote.txt”; //File holding quotes
$fp = fopen($quoteFile, “r”); //Opens file for read
$quotecontent = fread($fp, filesize($quoteFile)); // Read File
$quotes = explode(“\n”,trim($quotecontent)); //Put quotes into array
fclose($fp); //Close the file
$rquote = array_rand($quotes); // Random Number

// Begin Page Layout HTML

- In the same function, add between:
[div id="header"]
[ ?php echo($blog_config[ 'blog_title' ]); ?]
[/div]

[div id='rquote'][ ?php echo ($quotes[$rquote]); ?][/div]

[div id="pagebody"]
[table border="0" width="[?php echo( $page_width ); ?]” cellspacing=”0″ cellpadding=”0″ align=”left”]

- Open your’s style.css in your themes directory
(example: themes/default/style.css)

- If you want to have the quote were i have it,
change the #header style and add the bellow #rquote:

#header
{
color: #FFF;
margin: 0px;
padding: 8px 8px 0px 8px;
background-color: #996;
font-size: 17px;
font-weight: bold;
background-color: #996;
}

#rquote
{
margin: 0px;
padding-right: 8px;
text-align: right;
color: #FFF;
font-size: 9px;
font-weight: bold;
border-color: #666;
border-style: solid;
border-width: 0px 0px 1px 0px;
}[/table][/div]

Now you have random quotes, just have to add more lines to quote.txt now :)

One Response to “sphpblog random quotes”

  1. Steve Says:

    Thanks for the tip. I will give this a try on my blog.

Leave a Reply

What is 7 + 2 ?
Please leave these two fields as-is:
IMPORTANT! To be able to proceed, you need to solve the following simple math (so we know that you are a human) :-)