Announcement

#1 2013-09-09 17:22:03

urzahil
Member
2013-09-09
2

Random quote

Hi,
I'm looking for a plugin to display a random quote from a pool (either on a text file or in the database). I tried "PWG Stuffs" as it has an option called "Random Quote" but it doesn't seem to be capable of rotating quotes (at least, I've not found any separator).
Is there a similar plugin available?

Offline

 

#2 2013-09-09 17:34:46

mistic100
Former Piwigo Team
Lyon (FR)
2008-09-27
3277

Re: Random quote

What does "rotating quotes" means ?

I think you can totally use the PWG Stuff block by creating a custom PHP script which give this kind output
http://citations.hasarddujour.com/citat … u-jour.php (Ctrl+U for real output)

Offline

 

#3 2013-09-10 12:12:56

urzahil
Member
2013-09-09
2

Re: Random quote

Rotating means display a different quote every time I reload the page.
I'll give a try to your suggested solution.

Last edited by urzahil (2013-09-10 12:13:42)

Offline

 

#4 2013-09-10 18:20:07

ddtddt
Piwigo Team
Quetigny - France
2007-07-27
7207

Re: Random quote

In the personal plugin

define('CIT_PATH', PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)) . '/');

add_event_handler('loc_begin_index', 'citations');

function citations()
{
  global $conf, $page, $template, $tab, $cit, $nbr  ;

  if (isset($page['section']) and $page['section'] == 'categories' and !isset($page['category']))
  {
    $template->set_filename('citations', realpath(CIT_PATH.'citation.tpl'));

    $tab = file(CIT_PATH.'citations.txt') ;
    srand((double)microtime() * 1000000) ;
    $nbr = rand(0, (count($tab) - 1)) ;
    $cit=$tab[$nbr];
     
    $template->assign(array('CITATIONS' => $cit));
   
     $template->assign_var_from_handle('PLUGIN_INDEX_CONTENT_BEFORE', 'citations');
  }
}

by FTP

add in directory personalplugin

a file citation.tpl with

citation.tpl wrote:

<div class="content">
      <h2>Citations</h2>
    {$CITATIONS}
    </div>

and file citations.txt with by line examble

citations.txt wrote:

Alphonse Allais : Impossible de vous dire mon âge, il change tout le temps.
    Christophe Colomb : On ne va jamais aussi loin que lorsqu'on ne sait pas où l'on va
    Georges Courteline, Ecrivain français :  Pour savoir qu'un verre était de trop, encore faut-il l'avoir bu.
    Cicéron : On voit qu'un ami est sûr quand notre situation ne l'est pas.
    Voltaire :  Courtes lettres et longues amitiés, tel est ma devise.


You love Piwigo so don't hesitate to participate, learn more on the "Contribute to Piwigo" page. If you don't have much time for contribution, you can also help the project with a donation.

Offline

 

Board footer

Powered by FluxBB

github twitter newsletter Donate Piwigo.org © 2002-2024 · Contact