Jump to:

22999 Posts in 11854 Topics by 2828 members

General Questions

SilverStripe Forums » General Questions » Link/URLField

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: 899 Views
  • Imbrondir
    Avatar
    Community Member
    13 Posts

    Link/URLField Link to this post

    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?

  • swaiba
    Avatar
    Forum Moderator
    1769 Posts

    Re: Link/URLField Link to this post

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

  • Imbrondir
    Avatar
    Community Member
    13 Posts

    Re: Link/URLField Link to this post

    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.

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