Jump to:

5452 Posts in 1673 Topics by 1197 members

Customising the CMS

SilverStripe Forums » Customising the CMS » ModelAdmin with Hierarchy

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

Page: 1
Go to End
Author Topic: 907 Views
  • Bambii7
    Avatar
    Community Member
    254 Posts

    ModelAdmin with Hierarchy Link to this post

    I'm in the process of attempting a basic directory system with ModelAdmin. It's obviously all possibly, but when looking through some of the CMS code it goes over my head a little.

    I'm using the example of Category and Product. I've added
       static $extensions = array(
          "Hierarchy",
       );
    to the Category dataobject
    and    static $tree_class = 'Category';
    to what I've called CategoryAdmin
    Then this little beauty
       public function SiteTreeAsUL() {
          $obj = singleton($this->stat('tree_class'));
          $obj->markPartialTree();
          
          if($p = $this->currentPage()) $obj->markToExpose($p);
       

          $siteTreeList = $obj->getChildrenAsUL(
             '',
             
             '"<li id=\"record-$child->ID\" class=\"$child->class " . $child->markingClasses() . ($extraArg->isCurrentPage($child) ? " current" : "") . "\">" . ' .
             '"<a href=\"admin/directory/Category/ResultsForm?Title=test&ResultAssembly%5BID%5D=ID&ResultAssembly%5BStatus%5D=Status&ResultAssembly%5BTitle%5D=Title&SecurityID=000000&ajax=1\" >" . $child->Title . "</a>" ',
             //'"<a href=\"" . Director::link(substr($extraArg->Link(),0,-1), "Category", $child->ID, "edit") . "\" >" . $child->Title . "</a>" ',
             $this,
             true
          );   

    I was using //'"<a href=\"" . Director::link(substr($extraArg->Link(),0,-1), "Category", $child->ID, "edit") . "\" >" . $child->Title . "</a>" ',
    which worked well to edit the tree.
    But............. '"<a href=\"admin/directory/Category/ResultsForm?Title=test&ResultAssembly%5BID%5D=ID&ResultAssembly%5BStatus%5D=Status&ResultAssembly%5BTitle%5D=Title&SecurityID=000000&ajax=1\" >" . $child->Title . "</a>" ',
    has been giving me a few issues. I think the above code is working but not returning the result to AdminRight? I was getting a lot of errors but the above link makes looks like it would work.

    I'm I missing a parameter?
    Does anyone have any clues or suggestions?

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