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.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Data Model Questions /

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

Set ParentID in RemodelAdmin? Plus a few more (partially SOLVED :))

Go to End

2 Posts   718 Views


Community Member, 66 Posts

9 October 2011 at 4:46am

Hi guys, I am setting up a site for a kind of news roll with articles and I decided to go with Uncle Cheese's RemodelAdmin interface to manage it since the SiteTree clearly won't work for 5+ news pieces a day (thought tangent here: PLEASE PLEASE 3.0 come ASAP). I have 2-3 days to figure this one out - I'd really appreciate any help!

I will have several Category pages scattered around the SiteTree which will hold ArticlePages. I would like a way to set the parent in ReModelAdmin via a dropdown.

1. Can we add fields to ModelAdmin itself so or would I need to do the dropdown inside the ArticlePage? If there is a possibility, how do I access that field on creating a new object? Ideally, I'd like to set the parent in (Re)modelAdmin

2. How can I hide the current behavior tab - what's the name in the CMS, behavior, behaviour or do I need a _t function if someone's CMS profile is in Spanish?

3. Is it ok to override the ParentID dropdown in the behavior tab with a different one?

4. How do I filter SiteTree objects in a dropdown based on a user's permission (e.g. if you have Edit privileges, it will appear there)?

5. I didn't understand how to hide children from Category nodes in the Sitetree from Uncle Cheese's RemodelAdmin article. Can you explain that again? Is there a way to filter the tree request to database, not hiding the pages on the front-end via CMS? (e.g. I have children pages on subsites that I want to show in the tree, but not the parent which is uneditable).


Community Member, 66 Posts

11 October 2011 at 11:34am

Edited: 11/10/2011 11:38am

Resolved a lot of things myself :)

1. There are a few errors in the RemodelAdmin.php that prevented the dropdown of possible parents to show (if the parent actually isn't set). Not sure exactly which line (since I added a few above), I think 92-ish, in RemodelAdmin.php, under method EditForm(). Find the elseif... it needs to be like:

elseif($parent_class = $this->parentController->parentController->stat('parent_page_type')) {


(one "parentController->" is missing and the sitetree can't get the reference for the page type.)

Also, I didn't like the fact that pressing Add.. and not saving left the page hanging in the root, it would be better for it to hang under the set parent page. Also wanted the page to get a temporary title. Fixed RemodelAdmin.php, the add() method under RemodelAdmin_CollectionController...

function add($request) {
		$class = $this->modelClass;
		$record = new $class();
		$record->Title = "New ".$class;
		if($p=$this->parentController->getParentPage()) {
			$record->ParentID = $p->ID;
		$class = $this->parentController->getRecordControllerClass($this->getModelClass());
		$response = new $class($this, $request, $record->ID);
		return $response->edit($request);

This way the parent is added before writing the first object. This one will then appear in the list even if we don't save it. Nice touch.

Now I am thinking of using Subsites, and wonder if there's a better way to set the parent since two pages may have the same URLSegment.

2. Use _t('SiteTree.TABBEHAVIOUR')...

3. Yup of course it is... Silly question, actually. I think I was going for something else, but super tired :)

4. Not figured out yet.

5. Solved by using the "hidepages" module from here:

For now, I'm good, I'm really curous about #4 if anyone.