Is there such a thing? I want to store a list of links related to a page, editable from the CMS. And it should work like the link widget in the HTMLEditor. Is this possible?
We've moved the forum!
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.
Hi,
I'm not sure how much of this can be done exactly the same way, but I would create a DataObject like...
class MyLinkURL extends DataObject {
static $db = array(
'LinkURL' => 'Varchar',//possibly use HTMLfield to allow creating a link in that way...
);
}
then I'd add has_many to the Page type required, then add the has_many as a tab when editting the page
...
static $has_many = array(
'MyLinkURLs' => 'MyLinkURL',
);
...
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab("Root.Content.MyLinkURLs",
new ComplexTableField(
$this,
'MyLinkURLs',
'MyLinkURLs'
)
);
return $fields;
}
...
Thanks for the tip. I had sort of given it up already and simply faked it using virtual pages. Kind of user friendly, but the urls gets messy.
I'll look into your tip.