Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tree Structure for file list #2

Open
twodayslate opened this issue May 20, 2013 · 4 comments
Open

Tree Structure for file list #2

twodayslate opened this issue May 20, 2013 · 4 comments

Comments

@twodayslate
Copy link
Contributor

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

Thanks!

@twodayslate
Copy link
Contributor Author

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 mentioned this issue May 21, 2013
@twodayslate
Copy link
Contributor Author

   <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">
    $SiteTreeAsUL
</div>

Could work with a little editing?

@twodayslate
Copy link
Contributor Author

 /**
 * 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
Copy link
Owner

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
Projects
None yet
Development

No branches or pull requests

2 participants