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
This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.
Please use forum.silverstripe.org for any new questions
(announcement).
The forum archive will stick around, but will be read only.
You can also use our Slack channel
or StackOverflow to ask for help.
Check out our community overview for more options to contribute.
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
How to write the control please help!
these way? <% control RandomImage(gallery) %>
Thanks for Help!
---Stooni
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)" />
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
make sure your function can be reached (put it in your base - page class to test)....
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
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....
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