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 – checking for edit mode


There are situations where you have to know if the user is currently editing the page. For example, the in-site editing toolbar sometimes causes problems because it shifts down a few elements. If your layout has been built using absolutely positioned layers, you probably have to move down the layers a bit in case the toolbar is visible.

The current page object can be accessed by using the variable $c, which contains a method that returns true if the page is currently in the edit mode. The following code will output a short sentence, but only if the page is in the edit mode. You can put the following little bit of code in default.php again or any other template you like:

<?php
if ($c->isEditMode()) { 
echo 'You are editing this page at the moment!';
}  

$b = new Area('Main');
$b->display($c);
?>

What just happened?

By calling the isEditMode method on the current page, which you can access by $c, you can check if the user is currently editing...