Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Design How to show tree view with 100 pages in a folder as tree view on browser.

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #210348
    grpramod
    Participant

    Hello All,

    How to show tree view with 100 odd pages in a folder as tree view on browser.
    Also user should be able to re order that pages, he can swap 100th page to 1st and viceversa,

    Any help appreciated.

    Thanks

    #210367
    Beverleyh
    Participant

    You could build a sortable file list using PHP’s glob() function http://php.net/manual/en/function.glob.php to get all the pages in a folder;

    $files = glob('path/to/pages/*.{htm,html,php}', GLOB_BRACE); // get all pages from a folder
    /* perform additional sort here */
    echo "<ul>\n";
    foreach ($files as $file) { 
        echo "<li>$file</li>\n"; 
        } 
    echo "</ul>\n";
    

    This would list the pages. You’d need to manipulate the output of ‘$file’ some more, and echo out whatever HTML markup you need to build your tree view (using CSS to dress it up).

    For the sort feature, you could do it with PHP or JavaScript. With PHP you could pass a query string via a link on the page;

    <a href="?sort=az">A-Z</a> | <a href="?sort=za">Z-A</a>
    

    And use PHP’s GET to identify which sort direction has been selected – something like;

    $sort = $_GET['sort'];
    if ( $sort == 'az' ){ sort($files); }
    else if ( $sort == 'za' ){ rsort($files); }
    

    This code would go where /* addition sort */ is indicated in the PHP block earlier.

    Alternatively, you could sort the files with JavaScript using one of the many available scripts / plugins that you can source online http://www.jqueryrain.com/demo/jquery-sortable-sort/
    Match your echo’d markup to that required by your chosen plugin.

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘Design’ is closed to new topics and replies.