Jump to:

23450 Posts in 18899 Topics by 2877 members

General Questions

SilverStripe Forums » General Questions » Rewriting SiteTreeAsUL for Admin Tab - Help?

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

Page: 1
Go to End
Author Topic: 995 Views
  • otherjohn
    Community Member
    125 Posts

    Rewriting SiteTreeAsUL for Admin Tab - Help? Link to this post

    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>" ',

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

  • otherjohn
    Community Member
    125 Posts

    Re: Rewriting SiteTreeAsUL for Admin Tab - Help? Link to this post

    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?

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.