5099 Posts in 1519 Topics by 1116 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1749 Views |
-
Adding a TreeMultiselectField to a page type

16 January 2009 at 12:46pm
Hi everyone!
I am pretty new to SS and I have to say I LOVE IT!!!
I would like to create a page type that includes a TreeMultiselectField where a user could select multiple options from an expandable tree type menu while editing that page type in the admin section.
Does anyone have an example of a class that can build and populate(with options I could define) the menu, and then add it into Root.admin.main so that the end user can use the tool??
I would really appreciate any help you have to offer...
-
Re: Adding a TreeMultiselectField to a page type

16 January 2009 at 1:38pm
You can run getChildrenAsUL() on any object to recursively build out its children. For instance, the menu on the left in the Site Content view of Silverstripe runs singleton('SiteTree')->getChildrenAsUL() (that is, essentially, every page that has been created). One of the arguments it takes is the "template" for the LI... so you can put special classes or hooks in there. I think that's in DataObject.php for reference. Might just look it up in the docs.
-
Re: Adding a TreeMultiselectField to a page type

16 January 2009 at 2:37pm
What you are saying making alot of sense, but to be honest it is a little over my head.
I work for a school in New Jersey, US, and I am trying to develope a system for "online lesson planning". The one request I keep getting is for the teachers to be able to select the applicable "standards" from a list.
The "standards" are dictated by the state and are formated like:
1 - math
1.1 - general
1.1.1 - addition
1.1.2 - subtractionIdeally there would be a check box or some method of "adding" for each speficic standard.
Is this reasonable?
___________________________________________________________
In Tutorial 2 it shows you how to dispaly the children of another section of the site.
Can you use a similiar technique in the .php files in the 'code' folder to call the children of another area of the site?
::Hope that makes some sort of sense::
-
Re: Adding a TreeMultiselectField to a page type

16 January 2009 at 3:35pm
Okay. What is the source of the whole standards hierarchy? Is it static? Or is this stored dynamically in the database?
-
Re: Adding a TreeMultiselectField to a page type

16 January 2009 at 4:01pm
Actually, if my 15 credits of a masters degree in education serves me right, then you're probably looking at a population of standards that rarely changes. Let's assume that you have added all the standards, in order, to the Standards table.
/mysite/code/Standard.php
class Standard extends DataObject
{
static $db = array ('Name' => 'Varchar(50)','Number' => 'Varchar(10)');
static $belongs_many_many = array ('Lesson');}
/mysite/code/Lesson.php
class Lesson extends Page
{
static $many_many = array ('Standards' => 'Standard');public function getCMSFields()
{
$f = parent::getCMSFields();
$f->addFieldToTab("Root.Content.Standards",new CheckboxSetField('Standards','Standards (check all that apply)', DataObject::get("Standard")->toDropdownMap()));
}
}
| 1749 Views | ||
|
Page:
1
|
Go to Top |

