Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Archive

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

silverstriping a site with random pictures


Reply

22 Posts   8694 Views

Avatar
stooni

16 August 2008 at 3:29am (Last edited: 16 August 2008 3:31am), Community Member, 89 Posts

I have insert the function in the File AssetAdmin.php these is in the folder cms\code.

And now in the SideBar.ss under the sidebarBottom ihave insert
<div><% include $RandomImage(gallery) %> ???? it is not

thanks

---Stooni

Avatar
stooni

18 August 2008 at 8:11pm Community Member, 89 Posts

How to write the control please help!

these way? <% control RandomImage(gallery) %>

Thanks for Help!

---Stooni

Avatar
Fuzz10

18 August 2008 at 8:49pm Community Member, 787 Posts

The example RandomImage() Method returns the filename of the image , so in the template you can probably call the method immediately (without a control) , to get a filename :

e.g. <img src="$RandomImage(mydirectory)" />

Avatar
stooni

18 August 2008 at 10:02pm Community Member, 89 Posts

I give these in the file

<img src="$RandomImage(assets/gallery)" alt="$Title photo" />

an i become this in the code,    

<img src="" alt="About Us photo" /></p>

I think the function can not be found.

--Thanks
Stooni

Avatar
Fuzz10

19 August 2008 at 12:13am Community Member, 787 Posts

make sure your function can be reached (put it in your base - page class to test)....

Avatar
stooni

19 August 2008 at 9:45pm Community Member, 89 Posts

I have inserted theses
function RandomImage( $strLeftDirName )   
{
if ( !is_string( $strLeftDirName ) )
{
return false;
}
$left_dir = DataObject::get_one("Folder", "Name = \"$strLeftDirName\"");
$randImg = ( $left_dir->ID ) ? DataObject::get_one("Image", "ParentID = $left_dir->ID", true, "RAND()" ) : false;
return $randImg->Filename;
}

in the function class Page_Controller extends ContentController in the site mysite\code\Page.php and i becoming these Errors.
Notice: Trying to get property of non-object in C:\xampp\htdocs\ss099\mysite\code\Page.php on line 25

Notice: Trying to get property of non-object in C:\xampp\htdocs\ss099\mysite\code\Page.php on line 26

Thanks

--Stooni

Avatar
Fuzz10

20 August 2008 at 12:25am Community Member, 787 Posts

Is the error being thrown on this line ?

$randImg = ( $left_dir->ID ) ? DataObject::get_one("Image", "ParentID = $left_dir->ID", true, "RAND()" ) : false;

Then check if SS finds your directory correctly....

Avatar
stooni

20 August 2008 at 6:18am (Last edited: 20 August 2008 6:18am), Community Member, 89 Posts

Thanks its going!!! yuupie!
   
Now I only need to get the small Tumbnails be displayed.!
with these command <img src="$RandomImage(gallery)" alt="$Title photo" />

   
I hope I get to do otherwise I am back in the forum.

Thank you very much!

---Stooni