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

Avatar
socks

Community Member, 191 Posts

16 March 2013 at 8:46pm

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

Forum Moderator, 1132 Posts

18 March 2013 at 1:17am

Something like this?

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

Avatar
socks

Community Member, 191 Posts

18 March 2013 at 6:25am

That worked :)

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

Thank you!