Documentation

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

content() function

As its name suggests, the content() function returns the content of pages created in Wolf. More specifically, it returns the content of the page-part given as a parameter; if no parameter is given, then it defaults to the body page-part, circled in red in this graphic:

Page-part tabs

In order to display the body, put this code at the appropriate place in your layout:

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

Other content parts can be created by clicking the green “+” icon above the upper-right corner of the page editing box. (The red “-” icon deletes the active part/tab, so be careful!)

Page-part (tab) creation button

If you need to display one of these “custom” parts, like the sidebar tab in the Home Page graphic above (circled in blue), just add it to the parameter:

<?php echo $this->content('sidebar'); ?>

Note: if you use <?php echo $this->content(); ?> in page content, it will create an infinite loop: so don’t do it! In other words, only use that code for the page body tab in a Layout, not in a Page.)

"Inheriting" content

In order for the “part” to be inherited by “child” pages (and “child-of-child” pages, etc.), use the true parameter:

<?php $this->content('sidebar', true); ?>

Note: if the current page has its own equivalent “sidebar” part, then that will prevent the “inheritance” from the parent page from taking place.

Displaying the content of one page on a different page

If you want to call the content from a some page onto a different page, you must use the find() function in conjunction with content(). For example, to display the content of the default “About us” page on any other page, use this code:

<?php echo $this->find('about_us')->content(); ?>
 
functions/content.txt · Last modified: 2012-06-07 09:00 by David
 
Except where otherwise noted, content on this wiki is licensed under the following license:GNU Free Documentation License 1.2
Copyright 2010 wolfcms.org / design by yello studio / Wolf CMS Inside