Jump to:

23478 Posts in 18941 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » Best solution for layout

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: 762 Views
  • sca123
    Community Member
    61 Posts

    Best solution for layout Link to this post

    In the attached example, you will see that I have a number of 'title boxes' that have a title, image, text, and link. I would like to be able to add/edit/delete these through Silverstripe - so what is the best way to set this up? Could you use the DataObjects module??

    Some assistance would be appreciated both on the backend and frontend side of how this would work.


  • _Vince
    Community Member
    161 Posts

    Re: Best solution for layout Link to this post

    I have something like that on some pages. I basically define all that in the CMS

    class MyPage extends Page {
       public static $db = array(
    'SideBar_Img_Comment' => 'Text'
       public static $has_one = array(
    'SideBar_Img' => 'Image',
    'SideBar_Link' => 'SiteTree'
       function getCMSFields(){

          $fields = parent::getCMSFields();

    $fields->addFieldToTab("Root.Content.LeftHandSideBarContent", new FieldGroup(
    new TreeDropdownField("SideBar_LinkID",
    "<b>SideBar Image 1</b><br />Select the page to link to and then choose the image to display",
    new ImageField('SideBar_ImgID','')));
          $fields->addFieldToTab("Root.Content.LeftHandSideBarContent", new TextField('SideBar_Img_Comment', "Image Caption"));


    return $fields;


    After which I just place $ShowCase1_Link_ID (and so on) in the template.

    Is that any help?

  • banal
    Community Member
    901 Posts

    Re: Best solution for layout Link to this post

    DataObjectManager would definitely be appropriate here.
    Just create a custom DataObject class with Title, Image and Text field (maybe together with a link to a page of yours). In the template you would simply loop/output all the DataObjects.
    Should be a straight forward thing to do. You'll find the dataobjectmanager documentation here: http://doc.silverstripe.com/doku.php?id=modules:dataobjectmanager

  • AdamJ
    Community Member
    145 Posts

    Re: Best solution for layout Link to this post

    I actually wrote a little extension that I use in-house that is basically templated articles. I have a data-object manager that attaches articles to a page (with title, subtitle, image, content and a couple miscellanious fields), and then also a dropdown list of templates. These templates are added to the template directory in the filesystem for SS, and are defined in a modeladmin interface.

    This basically allows me to have a list of articles on a single page (and an article here could be simply a small heading, some copy and an image) and then give each of those articles a different template, and the extension takes care of the rest.

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.