Jump to:

3372 Posts in 998 Topics by 712 members

Data Model Questions

SilverStripe Forums » Data Model Questions » Set ParentID in RemodelAdmin? Plus a few more (partially SOLVED :))

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

Page: 1
Go to End
Author Topic: 349 Views
  • KINKCreative
    Avatar
    Community Member
    56 Posts

    Set ParentID in RemodelAdmin? Plus a few more (partially SOLVED :)) Link to this post

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

  • KINKCreative
    Avatar
    Community Member
    56 Posts

    Re: Set ParentID in RemodelAdmin? Plus a few more (partially SOLVED :)) Link to this post

    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;
          };
          $record->write();
          $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:

    http://www.silverstripe.org/customising-the-cms/show/11471?start=32

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

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