Div With Background image

23 posts by 3 authors in: Forums > CMS Builder
Last Post: September 16, 2011   (RSS)

Hi all

I have a div that i want to have a background in and i want to make it so each time the page is loaded it will random the image background i have a multi section setup with the images in it all the same size but i just cant get it to work anyone help.
Thanks



Craig

KC Media Solutions

www.kcmedia.biz

Re: [kcmedia] Div With Background image

By robin - September 15, 2011

Hey Craig,

Could you post what you have so far and we'll see if we can help make it work?

Thanks,
Robin
Robin
Programmer
interactivetools.com

Re: [kcmedia] Div With Background image

In the list viewer bit, add
'orderBy' => 'RAND()',
'limit' => '1',

This will give you a single, random record.

Then, for the div...

<div style="background-image="<?php for each....>">
content...
</div>
Cheers,

Tim (toledoh.com.au)

Re: [robin] Div With Background image

Hi Robin

here is the file just wont work keep getting an error in the code and wont show the image.
Thanks



Craig

KC Media Solutions

www.kcmedia.biz
Attachments:

index_040.php 6K

Re: [kcmedia] Div With Background image

Hi Craig,

How have you got home_bg set up. Is it a single item, with the ability to upload multiple images, or is it a multi-item where you create a record for each image?

I normally use the mulit record option, and this is what I have responded to above. If you do the same, you ned to have 2 "for each" loops. The first for each "home_bg" record (of which you are limitting to 1 random record), and the second loop for each "upload".

If using the single record with multiple uploads, forget the "limit and orderby" functions from my previous post, just have the standard viewer code, then before the <?php foreach ($home_bgRecord['image'] as $upload): ?> you will need to "shuffle" the records, then carry out the loop, and insert a <?php break ?> before the end tag to ensure you only display 1 of the images.

Hope that helps :)
Cheers,

Tim (toledoh.com.au)

Re: [kcmedia] Div With Background image

Try this and let me know how you go.
Cheers,

Tim (toledoh.com.au)
Attachments:

index2_003.php 6K

Re: [Toledoh] Div With Background image

By KCMedia - September 15, 2011 - edited: September 15, 2011

Hi Tim

i tried that but still nothing here is the file i have updated in the code when it runs this what is says

<div id="home" class="main" style="background-image="style="background-image="/cmsAdmin/uploads/home-page-bg.png/cmsAdmin/uploads/home-page-bg_001.png/cmsAdmin/uploads/home-page-bg-1.png">
Thanks



Craig

KC Media Solutions

www.kcmedia.biz
Attachments:

index_041.php 6K

Re: [kcmedia] Div With Background image

try this?
Cheers,

Tim (toledoh.com.au)
Attachments:

index3.php 6K

Re: [Toledoh] Div With Background image

Hi Tim

still no good.

just remember that at the moment csmb sits on the root of the html dir but the files are up one dir in newsite
Thanks



Craig

KC Media Solutions

www.kcmedia.biz