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 – hiding content from anonymous visitors


Carry out the following steps:

  1. We've already seen how we can hide a page or even a block from a user by using the concrete5 user interface in combination with the advanced permission mode.

  2. Let's hide content by using some code. Put the following lines in default.php:

    <?php
    $u = new User();
    if ($u->isLoggedIn()) {
    echo '<a href="/secret/">Secret key to world domination</a>';
    }
    
    $b = new Area('Main');
    $b->display($c);
    ?>

What just happened?

The preceding two Time for action sections can both be used to change the content by adding some logic to the template.

While we've put both of them in a theme template, they are not only restricted to this location. You can use the command new User almost anywhere in concrete5. The method isEditMode also works at several places, theme templates, page list templates, or autonav templates.