For ubu roi and anyone else who is interested in a few of the tricks used on this site, here are a few bits of code that might help you out. Sadly, you can’t really do this stuff as plugins, which means you have to edit the code yourself. This will either be very easy or a little confusing, depending on how comfortable you are with PHP. Also, this code is only going to be useful if you’re using wordpress.
First, the random quote. Create a quotes file named “quotes.txt” and put it in the /wp-content filder. The file should have three lines for every quote: The first is the quote itself, the second is the person being quoted (leave blank if you dan’t want this) and the third is a required blank line. Mine looks like this. Now, somewhere in the PHP code for your site (I suggest at the top of the header.php) place this code:
<?php
/*-----------------------------------------------------------------------------
Pull out a random quote from the quote file and display it.
-----------------------------------------------------------------------------*/
function random_phrase ()
{
$quotes = file ("wp-content/quotes.txt");
$num = rand (0, intval (count ($quotes) / 3)) * 3;
echo $quotes[$num] . "<br>" . $quotes[$num + 1];
}
?>
Almost done. Now just put this little bit of code where you want the quote to appear:
<?php random_phrase (); ?>
Control
A wild game filled with wild ideas that features fun puzzles and mind-blowing environments. It has a great atmosphere, and one REALLY annoying flaw with its gameplay.
The Best of 2015
My picks for what was important, awesome, or worth talking about in 2015.
My Music
Do you like electronic music? Do you like free stuff? Are you okay with amateur music from someone who's learning? Yes? Because that's what this is.
DM of the Rings
Both a celebration and an evisceration of tabletop roleplaying games, by twisting the Lord of the Rings films into a D&D game.
Quakecon Keynote 2013 Annotated
An interesting but technically dense talk about gaming technology. I translate it for the non-coders.
T w e n t y S i d e d
awesome! I am definitely going to use that.
Can we get teh code for the small dice roller at the bottom of your sidebar next?
Yep, I was going to extract my old quote file and use it.. .then I remembered it wasn’t on Houblog, it was on a friend’s site I had admin to… and it’s gone. Rats. I had a great one from a movie on how it was against the university’s policy to make war on the United States. It was so ironic, given the politics of some faculties these days.
Excellent! Thanks so much!
I’m assuming you use something similar for the other random aspects of your site- instead of quotes is just code to display header/footer/diceroll.
Am I correct?
I agree with you , your done a great job~
You have done a great job. Thanks for the Lexikon Plugin.
Thanks for the code. I included this code in wordpress footer to get random quotes.
Thanks :D
def gonna use this on a couple of my blogs! thanks a lot mate
Can you make it so it uses the same file for the quotes. So instead of using the .txt file, you can store the quotes inside the .php file?
This will make the file more maintainable and it will use have better performance I think.
Thanks and kudos.
That’s a terrible idea. Segregation of code and data is almost always the way to go.
I love quotes, espcially motivation ones, they can really change your day :)
Anyway, nice idea , gonna use it on my blogs also, thanks!
Thanks for the handy tip!! That really is an useful piece of information. I have to say I love the way your blog is dressed especially those colored dice thing :)
Thanks for the code
Thank you for posting this. Very useful. We’re using this for showing testimonials in the footer our site.
On another note, I think there’s a small bug in the code – with the offset. We tried the following and it seems to work more consistently:
function random_phrase () {
...
$num = rand (0, intval (count ($quotes) / 3) - 1) * 3;
...
}
Hope this helps.