Hi community,
Well i've been struggling with Silverstripe for some time now and its all lovely etc.
I wanted a nice function that retreived a random image from a specific ImageFolder.
I've search the forums and found something like this:
In my Page.php (mySite folder) i placed this:
function RandomImage()
{
return DataObject::get_one("Image","ParentID = 120",false, "RAND()");
}
This, as far as i know, retrieves an image from the folder with the id '120' (which is the correct folder)
Then the css part, i've tried two things:
nr1 (in the Layout.css file):
#header-photo {
clear: both;
height: 200px;
width: 790px;
margin: 0 auto;
/*background: #FFF url(../images/header4.jpg) no-repeat center center;*/
background: #FFF url($RandomImage()) no-repeat center center;
}
The one background that is the 'normal' static one which works
Result:
This results in a blank space where the image should be.
nr2 (In the Page.ss): (inline css)
<div id="header-photo" style="background-image: url($RandomImage())"></div>
Result:
This results in the same blank space at nr 1, BUT with the following text in it (without || and i did underline it) | ())"> |
Somewhere i am making a mistake (else it would work).
Like i've said i have read the forums but i just cant figure this one out.
Thanks in advance for the help