Plugin: Random Background main page

Vaska A / 2007-07-15 12:32:59   

I've released the random background for the main page plugin. This is a slightly advanced plugin, but is not difficult to use.

What does it do?
It places a random image into the background on the main page of your site.

How to install?
Download and add the plugin into your /ndxz-studio/site/plugin folder.

You need to edit your template in a text editor. Replace the 'backgrounder' plugin with:

<plug:ndxz_rand_bg folder_name,tiling />

folder_name: name of the folder which holds your images (you need to use ftp to place them).

tiling: 'true' for tiling...'false' for no tiling (big images).

Save your changes, test it. Be sure you have the name of the folder correct.

This is a slightly experimental plugin. If it does not work the first place you should check is on the name of the path to your images folder. Some servers may have difficulty finding this folder...if this is the case, use a hard-coded path.

Download @: plugin.ndxz_rand_bg.php.zip

Vaska A / 2007-07-15 12:46:32   

Demo page

Refresh the page a few times.

moodie / 2007-07-16 11:36:43   

Hey Vaska,

I've played around with this, but so far no luck. this is my code:

I made a folder in the files folder called 'random' which has my images in it, but am unsure as to where I am referencing the folder from? is it from the template file (which i am assuming is my index file in with the theme), or the index.php in the root directory?

thanks, aaron

moodie / 2007-07-16 11:37:38   

code isn't posting

(plug:ndxz_rand_bg files/random,false /)

Vaska A / 2007-07-16 11:47:56   

Something really isn't right there. It's not even producing the output. You sure the plugin is loaded into the plugin folder?

moodie / 2007-07-16 12:06:51   

i don't know what i did, but the plugin wasn't there ... its working now, though its tiling body bg and the 'false' isn't working ...

moodie / 2007-07-16 12:56:45   

vaska, couldn't get the image to stop tiling, so ended up editing the plugin and setting the css in there to 'no-repeat'. also found the image went into the right place by placing the x & y co ordinates in the 'background' css, as opposed to the 'background-position'.

Vaska A / 2007-07-16 13:04:39   

Niiiiiiiiiiiiice....

I made a note about the positioning...it seems you've adjusted your css so that adjustment is necessary. I'll fix the problem with true and false...I see where that is wrong.

Thanks for messing with that...we nabbed a bug in the process. ;)

moodie / 2007-07-17 09:38:15   

no problems! now I just got to get some images together to make it work properly .. :)

mejo / 2007-07-31 10:05:56   

Hi Vaska,

Followed all instruction carefully.
Images in ndxz-studio/rnd-images
updated template (the index.php in my template folder) so it says

and still nothing.

Ive tried playing with bits of the code and different alternatives but really not that sure what I'm doing.. will keep having a go though! Any ideas would be greatly appreciated.

Thanks,
Will

mejo / 2007-07-31 10:06:49   

to recap on the missing code:

...updated template (the index.php in my template folder) so it says.. plug:ndxz_rand_bg rnd-images,false /

W

Vaska A / 2007-07-31 12:04:11   

Nope...the name of the folder is fine, but the folder should exist in the ROOT of your site. Where you put your 'files' folder...place your 'rnd-images' folder at that level.

Gorcika / 2007-09-11 12:45:47   

Hi,
sorry but it doesn't work for me I did everything fine but now when I go to my website I have:

Parse error: syntax error, unexpected '(', expecting T_STRING in /home/wb55221/ndxz-studio/site/plugin/plugin.ndxz_rand_bg.php on line 17

and in the 'plugin.ndxz_rand_bg.php (which is the plugin folder), I wrote this:

function plug:ndxz_rand_bg files/image fond/fond boisA.jpg, false /
{
global $rs;

if ($rs['url'] == '/')
{
// get our images
$path = DIRNAME . "files/image fond/fond boisA.jpg";

if (is_dir($path))
{
if ($fp = opendir($path))
{
while (($module = readdir($fp)) !== false)
{
if ((eregi("jpg$", $module)) || (eregi("gif$", $module)) || (eregi("png$", $module)))
{
$images[] = $module;
}
}
}
closedir($fp);
}

$image = count($images);
$rand = rand(0, $image-1);

$show = BASEURL . "/$folder/" . $images[$rand];

$tile = ($tile == true) ? 'repeat' : 'no-repeat';

// this 215px setting may need to be adjusted if you have altered your Index in the template
$style = "body { background: url($show) $tile;\nbackground-position: 215px 0; }\n";
return $style;
}
else
{
return backgrounder($rs['color'], $rs['bgimg'], $rs['tiling']);
}

return;
}
WHAT'S WRONG ?
Thanks

Vaska A / 2007-09-11 13:57:38   

Don't touch the plugin itself in the plugin.ndxz_rand_bg.php file. When you add the plugin to your template...in to the space I say to do so...add it like...


<plug:ndxz_rand_bg 'files/image',false />

This is assuming that your images are going into the 'files' folder in another folder called 'image'.

Hope this helps.

alexkickham / 2007-10-12 08:52:21   

Instead of random uploaded images is it possible to use random url's? e.g. ones from your flickr account?

Vaska A / 2007-10-12 08:57:59   

If you write a plugin to do that it's possible. But, not with this one. Although you could try editing it up.

needlnerdz / 2007-10-22 10:21:30   

Of course I have to want to alter the way things are... and have such little knowledge as to how to do it. Could someone suggest how I might go about limiting the random background selection to only files with 'th-' in the front of them? I am using the main gimgs folder.. however the tiling only really works when it is from the thumbnail.. thus I'd like to filter the plugin to only look at those files. I came close in my altering- but was only able to get it to use the th- then add it to any other file.. so the 'sys' ones caused a blank background.

Any advice would be grand.

cheers

Markuz / 2007-11-02 13:03:34   

moodie said:

vaska, couldn't get the image to stop tiling, so ended up editing the plugin and setting the css in there to 'no-repeat'.

I'm having probs with the image repeating horizontally on wider screens.

Is this something I can edit?

mellotone / 2007-12-20 15:33:52   

Hi Vaska,

I installed the random image plugin and it seems to work no problem.However, now in the very upper left corner of my site is a piece of code showing that looks like the greater than/less than symbols

Here's my site www.russellaustin.com

Seems like this might be an easy fix I'm just not sure where to do this at.

thx

Vaska A / 2007-12-20 16:43:37   

I don't see a link to Indexhibit on your site...sorry...can't help you until you have one.

mellotone / 2007-12-20 18:16:11   

It was not intentional, that exhibit was hidden and now it is not.
Is that the link back to indexhibit that you were referring to?

Thx!

On a side note, I would like to be added to the participants list, if possible.

; )

Vaska A / 2007-12-20 18:33:31   

Whoa...first of all...what version are you using? That's oolllllddd...

Thanks for the link...your links make this project worthwhile for us and everybody.

The problem is pretty simple...in your template it appears that you have something leftover that should note be there...I see this...

I can't show it because I need to upgrade this forum...blah.

Between your '/script' tag and your 'head' tag there are the brackets that you should remove from the template.

The empty brackets should be removed.

;)

mellotone / 2007-12-20 18:51:55   

Right on.

I know, I've been reluctant to run the upgrade out of fear that it might lead to more problems. I just need to get on with it.

Thanks for the bracket tip.

Respect as always!

Vaska A / 2007-12-20 18:52:57   

Yes, wait on the upgrade though...new version soon. Big fundamental changes.

plugimi / 2008-01-19 20:49:55   

hm, where's that template? do you mean 'template.php'? or 'exhibit.backgrounded.php'? cheers, sascha

Vaska A / 2008-01-19 23:07:40   

Eh?

simon / 2008-01-20 10:03:53   

The template are located in /ndxz-studio/site/The folder "Eatock" is the one by default but you can use the "Sample" one (who is more customizable) by changing it in the Indexhibit preferences.

If you copy/paste and rename the sample folder, you can have as many templates as you want.

> Settings panel

Gav / 2008-02-08 12:07:36   

Hi Vaska - I can't download the plugin. it doesn't seem to be at the end of the link. can you send it to me or help?

thank you

gav (http://getinvolvedclub.com)

Vaska A / 2008-02-08 12:09:43   

Just go to the downloads page...

Gav / 2008-02-08 18:38:17   

I am officially a dullard. Thank you! I have a feeling I'll be re-reading this thread over the weekend as I try to make the randomizer work. Thanks again. People keep saying they like my site. I keep telling them I made it using indexhibit...

Axel / 2008-05-22 21:01:32   

Hi Vaska,

i am trying to get the random background plugin into my site - got thru the forum but sitting here with a big question mark over my head...

i don´t understand where "the template" is in which i can change the code?

is it possible to integrate the random backround plugin in a site which uses the eatock theme?
or do i have to create a new theme?

sorry for maybe asking stupid questions ;))
thanx in advance...

Vaska A / 2008-05-22 21:03:04   

No, the Eatock template is embedded into the system. Switch to the Sample template set and then you can edit the file at /ndxz-studio/site/sample/index.php

If you have edited up the style.css file in the Eatock folder simply copy and paste the contents in the style.css file in the Sample folder.

Axel / 2008-05-22 21:34:54   

when i open the file "index.php" in the folder "Sample" the content is:

•Built with Indexhibit

i understand that i change the look via css-styles but i don´t understand where to implement exactly the code for the background image plugin.

if i should have special php-knowledge to do it - in real life i´m a graphic designer ;)
so please tell me directly if i´m on a wrong path because of missing basic skills.

nickallen / 2008-05-25 22:21:13   

Hi - can anyone tell me how to change the background colour when using this plugin? Its currently set to white and I'd like to change it to black if possible... Cheers

thesupermarket / 2008-05-27 01:31:11   

hey nickallen,
i'm pretty sure you can change the bg color if you go to the home page of your site (the post/exhibit that comes up first) where the random image is being displayed and edit the background color there.

thesupermarket / 2008-05-27 01:36:56   

alright, my images are loading in a random fashion but they are tiling.
14sf/indexhibit

tried this
plug:ndxz_rand_bg bg,false /
and this
plug:ndxz_rand_bg 'bg',false /
and this
plug:ndxz_rand_bg bg,tile='false' /
nothin'

*******************************************
UPDATE : FIXED
I edited the plugin file and changed all trues to false.

nickallen / 2008-05-27 13:46:33   

thanks supermarket - I actually already tried changing the background colour from the home page as you suggested but it still displays as white on my site. I am assuming the random background plugin overrides this colour selection option in some way.

Does anyone else have any other ideas by any chance???

Nick

Vaska A / 2008-05-28 08:37:59   

how about showing us?

nickallen / 2008-05-28 19:26:39   

sorry my site is: nicksbook.net

Arrival / 2008-06-17 15:55:09   

I have this issue also, where the background colour is now just white, on all sections? Is there something I can edit on my PHP file?

bjw3003 / 2008-07-18 15:53:49   

Hi Vaska
Having the same problem with the white background as the guys above - any idea how to fix it?
Many thanks

Vaska A / 2008-07-18 19:27:41   

Guys, it has been posted around the forum many times...keep searching until it pops up.

talz / 2008-07-22 21:01:15   

this plugin is great. only thing I am thinking about now is this.

the size of my random background images are 1280 x 800. when I look at my site from my home computer (which is set to 1280 x 800) it looks great.

however, when I look at my site on another wider monitor (set at 1680 x 1050) the images tile slightly. you can see the image starting to repeat in the corners.

I think if I created the background images even larger (maybe 1680 x 1050 size) it would look ok on any resolution monitor...does that make sense?

Vaska A / 2008-07-22 21:13:39   

There is a trade off here between image size in pixels and in kilobytes. But, most people don't surf the web at 1680 width...it's much closer to 1280. There are stats out there...just do a google on something like "browser size statistsics" and I bet you'll find some helpful info to make your decision.

talz / 2008-07-22 23:48:40   

nice. I'll check it out.

wonder if 1280 x 800 or 1024 x 768 is more common.

cuz at 1024 x 768 it cuts off the image on the right due to the smaller width.

I'll report back!

you can see how it looks on your browser if you like:

talz.ca

UPDATE:

January 2008
Higher:38%
1024x768: 48%
800x600: 8%
640x480: 0%
Unknown: 6%

so, I made all look ok at 1024 x 768 and then it also looked ok at 1280 x 800 (although there is more blank space on the right hand side).          

anoonimo / 2008-08-31 18:53:24   

Hello, I installed the plugin, I have 3 images on the folder and it works well but once in a while (randomly), it appears a blank background. You can try and refresh, you'll see this happen: www.anoonimo.com.

Could it be a conflict? Can anyone help me?

Thank you

anoonimo / 2008-08-31 19:25:35   

solved

froeset / 2008-09-27 15:00:29   

This is a great plugin. It works great. I found it easier than I thought to reposition the background start position too!

http://www.tomfroese.com/portfolio

Thanks.

T

aperryz / 2008-10-03 23:49:07   

Question about where the tiling starts. How do you control where the tiling starts? I have it set to "false" on the template but it still tiles. Not the end of the world but the tiling is starting in an annoying place (not the top left).

Example: my site is http://www.aaronperryzucker.com and I would like the image to start where the left menu ends but it seems to be starting farther to the right. Did I screw something up somewhere?

purf / 2008-10-05 10:12:53   

aperry:

since your menu is not the default 215px wide, you need to adjust the background-position in the ndxz_rand_bg.php to the width of your menu (182?).

This thread has been closed, thank you.