Jump to:

5450 Posts in 1672 Topics by 1197 members

Customising the CMS

SilverStripe Forums » Customising the CMS » [Solved]Display data from dataobject in literalfield template page

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 437 Views
  • voodoochile
    Avatar
    Community Member
    44 Posts

    [Solved]Display data from dataobject in literalfield template page Link to this post

    Hi All

    I need a little help please.
    i am trying to display a template page in a tab in the cms and populate it with data from a dataobject,
    so far ...
    i have created the dataobject, and using modeladmin have setup the tabs to fill out the formdata, and have added a tab with a literalfield that calls a template to display the result. it seems to ignore the control blocks and the $fielddata tags.
    and to complicate matters their are several dropdowns that get thier data from several dataobjects.

    this page works perfectly in the frontend, however some users will only work in the cms side and need to see the finished form without having to go into the front.

    Hope this makes sense

    Thanks

  • voodoochile
    Avatar
    Community Member
    44 Posts

    Re: [Solved]Display data from dataobject in literalfield template page Link to this post

    Hi All

    After A long day of searching and pondering and sore eyes i managed to work this out

    Here is what i have done.

    mysite/code/DataObject.php

       function getData()
        {
        if($ViewPage = DataObject::get('DataObject'))
        {
        return $this -> customise(new ArrayData(array())) -> renderWith('ViewPage');
        }
        }

    // CMS fields

    $fields->addFieldToTab('Root.TabName', new LiteralField('Data View', $this->getData()));

    This Will Render a Page from a Template into a tab in your dataobject in the cms and populate it with the data from that object.

    Note: The template needs to be put into mysite/templates folder and if you create an includes folder the includes should work aswell.

    Hope this helps someone in the future

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