Jump to:

5513 Posts in 1732 Topics by 1218 members

Customising the CMS

SilverStripe Forums » Customising the CMS » TreeDropdownField - how to show subselect of SiteTree

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

Page: 1
Go to End
Author Topic: 1837 Views
  • Andre
    Avatar
    Community Member
    126 Posts

    TreeDropdownField - how to show subselect of SiteTree Link to this post

    Hi there I'm trying to emulate serveral blocks of same types which can be included in serveral Pages unrelated from their hirachy.

    I did the Following. Building a FolderObject (ElementsFolder) which inherited from SiteTree and an ElementObject (Element) which inherited from ElementsFolder. I positioned ElementsFolder in root without being seen in Search and Navigation. In the ElementsFolder I put serveral ElemtObjects. In my case the ElementObjects hold each a different set of 4 Pictures. Now instead of selecting all four pictures for each visible Page in the Sitetree, I can just select the preferred Pictureset from TreeDropDown. I'm still working on the way to clever extract the objects from the linked ElementObject, but thats not the Problem. I still have nice Ideas and will offer this as a Module when its running.

    My Problem ist, that I want to stritp down the TreeDropdown to only show the Subtree with the ElementsFolder and Element Objects. I tried the following, but I always get the full sitetree:

    class SomePage extends Page { // Redirector

       public static $db = array(
       );

    public static $has_one = array(
    'LinkToElement' => 'ElementsFolder'
    );

    function getCMSFields() {
    $fields = parent::getCMSFields();
    $fields->addFieldToTab('Root.Content.Main', new TreeDropdownField("LinkToElementID", "Take Element from:", "ElementsFolder"));
    return $fields;
    }
    }

    class SomePage_Controller extends Page_Controller {
    }

    Anyone with any Ideas?

  • Andre
    Avatar
    Community Member
    126 Posts

    Re: TreeDropdownField - how to show subselect of SiteTree Link to this post

    Hi there, I still found no solution for my Problem. Is there a way, to just include a subpart of the Sitetree into TreeDropdownField and not the full SiteTree?

    If Sitetree looks the following

    ROOT
    __|- Main 1
    __|__|- Sub1
    __|__|- Sub2
    __|- Main 2
    __|__|- Sub1
    __|__|- Sub2
    __|- Main 3
    _____|- Sub1
    _____|- Sub2


    I dont want to see all Main and Sub Pages in the Dropdown, I just want maybe The Subpages untder Main3 to be displayed in TreeDropdownField.

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