Light-weight, fast, simple and powerful!
Translations of this page?:
Table of Contents


level refers to the “distance” of a page in the tree from Home Page or, more precisely, the number of elements a given page is distant from the “root” in the URI. “Home Page” (or “root” in the URI) is at zero.

You can echo the level of a page to the screen using this code:

<?php echo $this->level(); ?>


In this URI: this page: is at this level: (home page) 0 (home page) 0 about-us.html 1 contact 2

It is important to note that the “archive” (“blog”) type pages work this way:

In this URI: this page: is at this level: articles 1 my-news 5
= my-news 5

In an “archive” setting, the level of my-news is always 5, even though it is the child of the articles page which is at level 1.

Usage note

level() is very useful in a test to keep things off the “Homepage” that should only appear “inside” the site:

<?php if ($this->level() != 0) : ?>
    ... do stuff inside the site, but not on the Homepage ...
<?php endif; ?>

The if() test checks to see if the level is not '0' (= homepage), and if not, whatever appears before the endif will be run.

functions/level.txt · Last modified: 2011-09-12 00:46 (external edit)
Except where otherwise noted, content on this wiki is licensed under the following license:GNU Free Documentation License 1.2
Copyright 2010 / design by yello studio / Wolf CMS Inside