Jump to:

22972 Posts in 11596 Topics by 2824 members

General Questions

SilverStripe Forums » General Questions » ->setFolderName with Page Title

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Page: 1
Go to End
Author Topic: 339 Views
  • socks
    Avatar
    Community Member
    190 Posts

    ->setFolderName with Page Title Link to this post

    I have multiple gallery pages (OurWorkPage) and would like to have a distinct setFolderName for each one. I've successfully added the ID to the folder name, but what I really want is the Title or MenuTitle of OurWorkPage.

    class ProjectImage extends DataObject {

    public static $has_one = array(
    'OurWorkPage' => 'OurWorkPage',
    'ProjectImage' => 'Image'
    );

    function getCMSFields() {
    $fields = parent::getCMSFields();

    $imageField = new UploadField('ProjectImage','Project Image');
    $imageField->setFolderName('Our-Work-Images-'.$this->OurWorkPageID);


    }

    }

    Thanks

  • martimiz
    Avatar
    Forum Moderator
    1035 Posts

    Re: ->setFolderName with Page Title Link to this post

    Something like this?

    $imageField->setFoldername($this->OurWorkPage()->URLSegment);

  • socks
    Avatar
    Community Member
    190 Posts

    Re: ->setFolderName with Page Title Link to this post

    That worked

    $imageField->setFolderName($this->OurWorkPage()->MenuTitle.'-Work-Images');

    Thank you!

    339 Views
Page: 1
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.