Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » silverstriping a site with random pictures

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

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

Page: 1 2 3
Go to End
Author Topic: 8625 Views
  • stooni
    Avatar
    Community Member
    89 Posts

    Re: silverstriping a site with random pictures Link to this post

    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

  • stooni
    Avatar
    Community Member
    89 Posts

    Re: silverstriping a site with random pictures Link to this post

    How to write the control please help!

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

    Thanks for Help!

    ---Stooni

  • Fuzz10
    Avatar
    Community Member
    787 Posts

    Re: silverstriping a site with random pictures Link to this post

    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)" />

  • stooni
    Avatar
    Community Member
    89 Posts

    Re: silverstriping a site with random pictures Link to this post

    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

  • Fuzz10
    Avatar
    Community Member
    787 Posts

    Re: silverstriping a site with random pictures Link to this post

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

  • stooni
    Avatar
    Community Member
    89 Posts

    Re: silverstriping a site with random pictures Link to this post

    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

  • Fuzz10
    Avatar
    Community Member
    787 Posts

    Re: silverstriping a site with random pictures Link to this post

    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....

  • stooni
    Avatar
    Community Member
    89 Posts

    Re: silverstriping a site with random pictures Link to this post

    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

    8625 Views
Page: 1 2 3
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.