Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Customising the CMS /

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

TreeDropdownField - how to show subselect of SiteTree


Go to End
Reply


2 Posts   1976 Views

Avatar
Andre

Community Member, 135 Posts

27 May 2009 at 8:03pm

Edited: 27/05/2009 10:11pm

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?

Avatar
Andre

Community Member, 135 Posts

3 June 2009 at 9:48pm

Edited: 03/06/2009 9:52pm

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.