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.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Rewriting SiteTreeAsUL for Admin Tab - Help?


Reply

2 Posts   1050 Views

Avatar
otherjohn

2 June 2010 at 1:48am Community Member, 125 Posts

Hi all,
I am setting up my own assetsadmin that instead of pulling from the regular assets folder on the server, it pulls from an assets folder on Amazon s3. I have my upload to S3 working but now I need to list my directories correctly. It looks like I need to do my own SiteTreeAsUL function which is currently writen like

/**
    * Return the entire site tree as a nested UL.
    * @return string HTML for site tree
    */
   public function SiteTreeAsUL() {

      $obj = singleton('Folder');
      $obj->setMarkingFilter('ClassName', ClassInfo::subclassesFor('Folder'));
      $obj->markPartialTree(30, null, "ChildFolders");

      if($p = $this->currentPage()) $obj->markToExpose($p);

      // getChildrenAsUL is a flexible and complex way of traversing the tree
      $siteTreeList = $obj->getChildrenAsUL(
         '',
         '"<li id=\"record-$child->ID\" class=\"$child->class" . $child->markingClasses() . ($extraArg->isCurrentPage($child) ? " current" : "") . "\">" . ' .
         '"<a href=\"" . Controller::join_links(substr($extraArg->Link(),0,-1), "show", $child->ID) . "\" class=\"" . ($child->hasChildFolders() ? " contents" : "") . "\" >" . $child->TreeTitle() . "</a>" ',
         $this,
         true,
         "ChildFolders"
      );   

      // Wrap the root if needs be
      $rootLink = $this->Link() . 'show/root';
      $baseUrl = Director::absoluteBaseURL() . "assets";
      if(!isset($rootID)) {
         $siteTree = "<ul id=\"sitetree\" class=\"tree unformatted\"><li id=\"record-root\" class=\"Root\"><a href=\"$rootLink\"><strong>{$baseUrl}</strong></a>"
         . $siteTreeList . "</li></ul>";
      }

      return $siteTree;
   }

I need to somehow parse from the XML file I get back from Amazon that shows my files and folder structure and plug it in.
Can someone point me into the right direction? I am having a hard time wrapping my head around this.
John

Avatar
otherjohn

2 June 2010 at 2:35am Community Member, 125 Posts

Actually, I have another idea. Can I just overwrite the sync function to upload the folder structure from my xml file to the database instead. Would that be a better idea?
John