Div With Background image
23 posts by 3 authors in: Forums > CMS Builder
Last Post: September 16, 2011 (RSS)
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.
Craig
KC Media Solutions
www.kcmedia.biz
Re: [kcmedia] Div With Background image
By robin - September 15, 2011
Could you post what you have so far and we'll see if we can help make it work?
Thanks,
Robin
Programmer
interactivetools.com
Re: [kcmedia] Div With Background image
'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>
Tim (toledoh.com.au)
Re: [robin] Div With Background image
here is the file just wont work keep getting an error in the code and wont show the image.
Craig
KC Media Solutions
www.kcmedia.biz
Re: [kcmedia] Div With Background image
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 :)
Tim (toledoh.com.au)
Re: [Toledoh] Div With Background image
It is a multi record option and i dnt really understand what you meant with the other bit.
Craig
KC Media Solutions
www.kcmedia.biz
Re: [kcmedia] Div With Background image
Tim (toledoh.com.au)
Re: [Toledoh] Div With Background image
By KCMedia - September 15, 2011 - edited: September 15, 2011
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">
Craig
KC Media Solutions
www.kcmedia.biz
Re: [kcmedia] Div With Background image
Tim (toledoh.com.au)
Re: [Toledoh] Div With Background image
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
Craig
KC Media Solutions
www.kcmedia.biz