Book Image

concrete5 Beginner's Guide

Book Image

concrete5 Beginner's Guide

Overview of this book

Table of Contents (19 chapters)
concrete5
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Time for action – building a file explorer-like navigation


  1. Create another directory structure for our template blocks/autonav/templates/tree.

  2. Within that directory create view.php, but this time we'll use a different approach. We only want to change the class name to keep the functionality separated from other autonav blocks on the same page. We also don't want to copy the default autonav block template to avoid redundant code. We're going to replace the ul class name on-the-fly:

    <?php 
    $bvt = new BlockViewTemplate($b); 
    $bvt->setBlockCustomTemplate(false);
    
    function nav_tree_callback($buffer) {
    	return str_replace('<ul class="nav">','<ul class="nav-tree">',$buffer);
    }
    
    ob_start("nav_tree_callback");
    include($bvt->getTemplate());
    ob_end_flush();
    ?>
  3. In another file called view.css, you have to place some layout instructions for our tree. The script works without this, but the tree would look a bit misaligned:

    .nav-tree li { list-style-type: none; }
    .nav-tree { margin...