[mod request] Rando...
 
Notifications
Clear all

[mod request] Random Quote

8 Posts
4 Users
0 Reactions
3,957 Views
(@jacci)
Posts: 503
Honorable Member
Topic starter
 

Random quote.

I have installed a random quote feature into my efiction and used the <!-- INCLUDESCRIPT BLOCK : ./myscript.php --> command and got it working just fine.

I can code the new quotes in via a txt file and that works pretty good, although is a little tedious.

What i was wondering, woudl it be possible to add to the admin section an 'add quote' field or something along those lines so that an admin can add a quote, the speaker, the episode or author or whatever they want.
This woudl then be saved to the tables in a feild similar to the reveiws or comments and then could be pulled randomly into a block the same way that a random story is pulled?

Perhaps add a submitted by field as well which could either be displayed or not?

I have no idea how to proceed to mod this and if anybody is interested in developing, that woudl be fantastic. I am going to try and do some research and figure it out myself, but i am afraid my php knowledge doesnt extend too far at the moment. It might be quite a while, if ever, i get going on it.

thanks jacci


why is nothing ever easy?
url: http://www.pretendercentre.com/missingpieces/     
php: 5.2.5  msql: 5.0.45-community
efic version: 3.4.3           latest patches: yes
bridges: none              mods: challenges, displayword, beta-search

 
Posted : 11/05/2007 12:09 am
(@fanfictionworld)
Posts: 149
Estimable Member
 

well i did have a random quote thing on my old 2.0 site but i lost it when my site was attacked so dont think I still have the files  and I dont really know enough php to code one for efiction v3 but I'd posibly be  interested in using the one that you have already  if you intend to release it


~Spikey~

my site url: http://www.fanfictionworld.org
efic version:3.5.3

 
Posted : 13/05/2007 6:28 pm
(@jacci)
Posts: 503
Honorable Member
Topic starter
 

Hi fanfictionworld,

if you are interested i could give you the script. It isnt actually mine, i found it and just tweaked it a little to make it work in eficiton.
Of course i have forgotten the link (typical) and have cleared my history and cookies (a regualar sunday night exercise).

I do have a copy of the script though if you want
It was released under a GNU General Public License so i assume that it is fine to share, although i dont know if that means i can post it here on the boards.
If one of the mods could let me know if it is okay, i will post it up, it is only a short script, if not, PM me and i can send it to you directly.


why is nothing ever easy?
url: http://www.pretendercentre.com/missingpieces/     
php: 5.2.5  msql: 5.0.45-community
efic version: 3.4.3           latest patches: yes
bridges: none              mods: challenges, displayword, beta-search

 
Posted : 13/05/2007 10:44 pm
(@fanfictionworld)
Posts: 149
Estimable Member
 

yeah if it was released under the GNU General Public License  then it should be ok to post but its best to check with a mod  and if they give the ok then I'd like to consider using it


~Spikey~

my site url: http://www.fanfictionworld.org
efic version:3.5.3

 
Posted : 15/05/2007 2:31 pm
(@jacci)
Posts: 503
Honorable Member
Topic starter
 

To see it in action it can be found here:Missing Pieces just above the Site news. Hit the home or refresh button to see it cycling through the quotes randomly. It has been styled separatley for each skin.

I am going to post it and if it is inapropriate, please feel free to take it down.

create a php file called quotes.php  and text file called quotes.txt and place both in your primary efiction directory

the quotes.php will be:

<?php
/************************************************************************
Sava's Random Quotes
Copyright (C) 2006 Sava Stefan (ssavaa@gmail.com)

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

More Info About The Licence At http://www.gnu.org/copyleft/gpl.html
*************************************************************************/

// The name of your quote file
$quote_file = "quotes.txt";

// Open the quote file
$fp = fopen($quote_file, "r");

// Read the contents and tokenize the file to individual quotes
$quotes = fread($fp, filesize($quote_file));
$array = explode("n",$quotes);
fclose($fp);

// Find a random quote
srand((double)microtime()*1000000);
$array_index = (rand(1, sizeof($array)) - 1);

// Show the random quote
echo $array[$array_index];

?>

then use  the code in your index.tpl for any skin you want it to show up in (or your header.tpl or footer.tpl if you wish)

<!-- INCLUDESCRIPT BLOCK : ./quotes.php -->

I have amended the txt file a little to allow styling of it to get quotes to display, just enter each quote on a new line. Enter will tell the script to go to new quote, so use <br> or <p> if you want a line break. Basic html properties are used.

Here is an example of how i have set up the .txt file so it can be styled.

<p class="quote">Your quote here<br> and some more here </p><p class="quote1">Ep blah blah: me</p>
<p class="quote">Ohh another quote</p><p class="quote1">Next ep: by me again</p>

etc etc, you can add as many as you like

to style them simply add
.quote {your stlye info}
.quote1 {bold etc}

to your css for each skin


why is nothing ever easy?
url: http://www.pretendercentre.com/missingpieces/     
php: 5.2.5  msql: 5.0.45-community
efic version: 3.4.3           latest patches: yes
bridges: none              mods: challenges, displayword, beta-search

 
Posted : 16/05/2007 10:32 am
(@dreamhowler)
Posts: 147
Estimable Member
 

Thank You! I have been looking for something like this for awhile. Now I just have to generate a long file of Harry Potter Quotes. πŸ™‚

It took me a bit to make it show up correctly on CSS Zen. Could get the box to show up, but the background was giving me a hissy fit. I finally had to put the call function in a table for it to work. Ahh well, at least it works! Now to add it to my other skins. πŸ™‚

Thanks again!


Current Version: 3.4.2
PHP 4
Mods: Challenges, Recommendations, Storyend, Display Word, Beta Reader, Bad Reviewer

 
Posted : 26/07/2007 1:26 am
 Elle
(@jenny)
Posts: 594
Honorable Member
 

Another variation of the PHP (this is from Amelie):

<?php
$quotes = file('quotes.txt');

$num = rand(0, count($quotes)-1);

echo $quotes[$num]; ?>

Works the same, basically the same ... just shorter.


archive: dramione.org
site: accio.nu

Available for skin/mod commission! πŸ™‚

 
Posted : 26/07/2007 5:54 am
(@jacci)
Posts: 503
Honorable Member
Topic starter
 

Yay dreamhowler, glad you like it and got it all sorted!!!

That other script is very much shorter indeed, will look at amending mine, thanks Jenny.


why is nothing ever easy?
url: http://www.pretendercentre.com/missingpieces/     
php: 5.2.5  msql: 5.0.45-community
efic version: 3.4.3           latest patches: yes
bridges: none              mods: challenges, displayword, beta-search

 
Posted : 26/07/2007 12:00 pm
Share: