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 /

ModelAdmin with Hierarchy


Reply


1031 Views

Avatar
Bambii7

Community Member, 254 Posts

10 July 2009 at 12:22pm

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?