- b2evolution CMS User Manual
- Developer Reference
- Website Skins/Themes
- Using Custom Item Templates
Using Custom Item Templates
When you edit a post type, you can define custom templates.
These custom templates will be used when displaying the Item/Post/Page in various places of the front-office (like disp = posts (List of Posts / Items), disp = single, etc.).
The templates can be either Quick Templates or a PHP Template.
Example with Quick Templates
TODO screenshots of standard post vs Recipe.
Example with PHP Template
Back-Office Set up
Let’s set up a "Movie Review" post type, like this:
Now, let’s create a new Movie Review Post:
Alternatively, you could also change the type of an existing post here:
Front office disp=single
Now, once you save this post, it will appear normally in all lists, but as soon as you try to display the post (disp=single
), then b2evolution will try to use a custom template.
In order to understand the following, you need to first read "Understanding the skin files" in the Skin Development Primer.
With a custom post type, b2evolution will vary it’s behavior in the following manner:
- Instead of trying to call the
single.main.php
template, b2evolution will try to callmovie_review.main.php
.- If not found, it will try
single.main.php
in the skin folder. - If not found, it will try
index.main.php
in the skin folder.
- If not found, it will try
- Instead of trying to include the
_single.disp.php
template, b2evolution will try to include_movie_review.disp.php
.- If not found, it will try
_single.disp.php
in the skin folder. - If not found, it will try
_single.disp.php
in the fallback folders.
- If not found, it will try
Here is an example of a custom .disp.php
template: _recipe.disp.php.zip
Front-office (disp=page
)
This works similarly for pages (disp=page
):
- Instead of trying to call the
page.main.php
template, b2evolution will try to callmovie_review.main.php
.- If not found, it will try
page.main.php
in the skin folder. - If not found, it will try
index.main.php
in the skin folder.
- If not found, it will try
- Instead of trying to include the
_page.disp.php
template, b2evolution will try to include_movie_review.disp.php
.- If not found, it will try
_page.disp.php
in the skin folder. - If not found, it will try
_page.disp.php
in the fallback folders.
- If not found, it will try
Here is an example of a custom .disp.php
template: _recipe.disp.php.zip