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.

General Questions

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

->setFolderName with Page Title


Reply

3 Posts   443 Views

Avatar
socks

16 March 2013 at 8:46pm Community Member, 190 Posts

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

Avatar
martimiz

18 March 2013 at 1:17am Forum Moderator, 1091 Posts

Something like this?

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

Avatar
socks

18 March 2013 at 6:25am Community Member, 190 Posts

That worked :)

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

Thank you!