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 – restricting numbers of blocks per area


By default, you can place as many blocks in an area as you want. However, there are situations where a restriction to a single block might have some advantages.

In an absolute positioned layout, it can happen that the Add To Main link overlaps with another area or you simply want to make sure that there's just a single image block in the header area.

  1. Open the theme template where you'd like to add a restriction to the number of blocks. default.php does the job again.

  2. Look for the PHP part where you specify the area and insert the highlighted line shown here:

    <?php
    $b = new Area('Main');
    $b->setBlockLimit(1);
    $b->display($c);
    ?>

What just happened?

By simply adding one more line to our area, we made sure that only one block can be inserted. This nifty little method makes sure that the interface stays clean and consistent. If you've made a wrong decision, no worries—the line can be removed without any problems at any time.