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   8884 Views

Avatar
stooni

Community Member, 89 Posts

16 August 2008 at 3:29am

Edited: 16/08/2008 3:31am

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

Community Member, 89 Posts

18 August 2008 at 8:11pm

How to write the control please help!

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

Thanks for Help!

---Stooni

Avatar
Fuzz10

Community Member, 787 Posts

18 August 2008 at 8:49pm

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

Community Member, 89 Posts

18 August 2008 at 10:02pm

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

Community Member, 787 Posts

19 August 2008 at 12:13am

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

Avatar
stooni

Community Member, 89 Posts

19 August 2008 at 9:45pm

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

Community Member, 787 Posts

20 August 2008 at 12:25am

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

Community Member, 89 Posts

20 August 2008 at 6:18am

Edited: 20/08/2008 6:18am

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