Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Tree Structure for file list #2

twodayslate opened this Issue · 4 comments

2 participants


I want to display all the files in a tree-like structure.

Am I on the right track that it would go something like

<% if Listing %>
<% control Listing %> --this loops through all the elements of listing (folder)
<% if ClassName = Folder %>
--- want to do listing again... how do I do this?
<% end_if %>
<% end_control %>
<% end_if %>

It would be great if I could get this to work just like the default tree structure in ss...



I understand that a stack can be used instead of recursion but I am unsure of what to put into the stack given the variables or how to iterate through the stack. I assume <% control Listing %> iterates through the output from listing(...) but I don't exactly understand how ss handles these things as I just delved in ss today.

@twodayslate twodayslate referenced this issue

Added filter #4

   <div class="cms-tree" data-url-tree="$Link(getsubtree)" data-url-savetreenode="$Link(savetreenode)" data-url-updatetreenodes="$Link(updatetreenodes)" data-url-addpage="{$LinkPageAdd('AddForm/?action_doAdd=1')}&amp;ParentID=%s&amp;PageType=%s" data-url-editpage="$LinkPageEdit('%s')" data-url-duplicate="{$Link('duplicate/%s')}" data-url-duplicatewithchildren="{$Link('duplicatewithchildren/%s')}" data-url-listview="{$Link('?view=list')}" data-hints="$SiteTreeHints.XML" data-extra-params="SecurityID=$SecurityID">

Could work with a little editing?

 * Return the entire site tree as a nested set of ULs
public function SiteTreeAsUL() {
    // Pre-cache sitetree version numbers for querying efficiency
    Versioned::prepopulate_versionnumber_cache("SiteTree", "Stage");
    Versioned::prepopulate_versionnumber_cache("SiteTree", "Live");
    $html = $this->getSiteTreeFor($this->stat('tree_class'));

    $this->extend('updateSiteTreeAsUL', $html);

    return $html

in code/controller/cmsmain.php

 public function getSiteTreeFor($className, $rootID = null, $childrenMethod = null, $numChildrenMethod = null, $filterFunction = null, $minNodeCount = 30) {
    if (!$childrenMethod) $childrenMethod = 'ChildFolders';
    return parent::getSiteTreeFor($className, $rootID, $childrenMethod, $numChildrenMethod, $filterFunction, $minNodeCount);

in code/controllers/assetadmin.php


Sorry, I don't have time at the moment to look into implementing this, but if you do get this functioning I'd be interested to see a screenshot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.