Tree Structure for file list #2

twodayslate opened this Issue May 20, 2013 · 4 comments


None yet
2 participants

twodayslate commented May 20, 2013

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



twodayslate commented May 21, 2013

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 referenced this issue May 21, 2013


Added filter #4


twodayslate commented May 22, 2013

   <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?


twodayslate commented May 22, 2013

 * 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


purplespider commented Jul 3, 2013

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