Pre-nav random image

bille2630 / 2011-10-24 15:08:24   

My homepage is http://www.msoerensen.dk
I have been able to put my logo in the pre-nav text,
but i have more styles of the logo, so I was wondering
if it is possible to make a random image selecter ?
So it just takes a radom style of my logo ?
I have look, and tried the javascript kind of it but couldn't
get it working.

Hope you can help me

bille2630 / 2011-10-24 15:09:36   

the homepage msoerensen.dk

Vaska A / 2011-10-24 15:36:39   

The big MGS logo at the right?

What I often recommend that people do is create an exhibit and leave it unpublished. Then, they can upload their random images to it.

If you were to create a simple plugin that grabbed images from that particular exhibit you could do what you wanted. Something along these lines...

  1. <plug:random_logo />

And the code...

  1. function random_logo()
  2. $OBJ =& get_instance();
  3. $background = $OBJ->rs->fetchRecord("SELECT * FROM ndxz_media 
  4. WHERE media_ref_id = '25' 
  5. ORDER BY RAND() LIMIT 0,1");
  6. return "<img src='" . BASEURL . "/files/$background[media_file]' />";

25 is made up - that should be whatever the 'id' is of the unpublished exhibit.

I am sure this needs more work but give it a try and we'll walk you through the rest.

;)

bille2630 / 2011-10-24 15:58:08   

Thanks, i will try that and report back of how it goes..

bille2630 / 2011-10-24 16:14:56   

I don't quite understand it
As far as i understand, i am supposed to make a plugin with this code:

function random_logo()
$OBJ =& get_instance();
$background = $OBJ->rs->fetchRecord("SELECT * FROM ndxz_media
WHERE media_ref_id = '25'
ORDER BY RAND() LIMIT 0,1");
return "";

I don't quite understand which parts of the text i shall write in..

And then in my pre-nav text i direct it to the plugin i make ?

Vaska A / 2011-10-24 18:24:51   

In pre-have you put this for the image...

  1. <plug:random_logo />

Then, you create a plugin in a file called "plugin.random_logo.php" and put the contents above in it. Open up another plugin to see how it works (you also need to add the opening PHP line.

Luis_Silva / 2013-01-03 13:39:14   

hello :)

my site is kunsthalle-lissabon.org/ and I'm trying to use this to randomize the logo. My only question is I don't know what is the id of the unpublished exhibit. Do you know where to find it?

Thanks!
Luis

This thread has been closed, thank you.