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 – dynamically loading concret5 content using jQuery


  1. As always, we need a new structure for our template. Make sure all these directories exist within each other: blocks, autonav, templatesanddynamic_loadbuilding this path blocks\autonav\templates\dynamic_load.

  2. Create a new file view.php with the well-known content:

    <?php 
    $bvt = new BlockViewTemplate($b); 
    $bvt->setBlockCustomTemplate(false);
    
    include($bvt->getTemplate());
    ?>
  3. All the magic happens in our JavaScript file view.js:

    $(document).ready(function() {
      $(".nav a").click(function() {
        var pageUrl = $(this).attr("href") + " #content > *";
    
        $("#content").slideUp("normal",function() {
          $("#content").load(pageUrl,"", function() {
            $("#content").slideDown("normal");			
          });
        });
    
        return false;
      });
    });
  4. After you've created all the files, go back to your page and change the Custom Template of the autonav block where you want to try the dynamic page loading.

What just happened?

After...