b2evolution b2evolution

  • Sign in
  • Sign up
  • About
  • Downloads
  • Hosting
  • Docs
  • Support
  • Sign in
  • Sign up
  • Manuals Home
  • Latest Updates
 
  1. b2evolution CMS User Manual
  2. Developer Reference
  3. Website Skins/Themes
  4. 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:

Using Custom Item Templates

Now, let’s create a new Movie Review Post:

Using Custom Item Templates

Alternatively, you could also change the type of an existing post here:

Using Custom Item Templates

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 call movie_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.
  • 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.

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 call movie_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.
  • 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.

Here is an example of a custom .disp.php template: _recipe.disp.php.zip

Created by fplanque • Last edit by fplanque on 2020-06-09 00:25 • •

No feedback yet

On this page

  • Example with Quick Templates
  • Example with PHP Template
  • Back-Office Set up
  • Front office disp=single
  • Front-office (disp=page)

Search the Manual

Content Hierarchy

  • b2evolution CMS User Manual
  • User's Guide
  • Installation / Upgrade
  • Front-office Reference
  • Back-office Reference
  • Developer Reference
    • Website Skins/Themes
      • Skin Development Primer
      • Loading additional resources into a skin
      • Where are the skin files?
      • CSS Guidelines
      • Targeted CSS Selectors
      • Introducing evoSkins
      • Modifying evoSkins
      • Creating evoSkins
      • Skin Tags / API
      • Styling widgets
      • Skin Quality Control
      • Using HTML 5 tags
      • Using Custom Item Templates
      • Using bootstrap classes in footers
      • Using Grunt
      • Dev Menu
      • How to add a Google Font (WebFont) ?
      • Custom Fields in a Template
      • Site Skins
    • Email Skins/Themes
    • b2evolution Files
    • Website Integration
    • Plugins
    • Debugging
    • Technical Reference
    • Hacks
    • Credits
    • Development
    • How to... (Customize)
    • Scheduled Tasks Reference
  • Operations Reference
  • Advanced Topics
  • Glossary
  • Archives
Multi-blog engine

This online manual is powered by b2evolution CMS – A complete engine for your website.

About b2evolution

  • What is it?
  • Features
  • Getting Started
  • Screenshots
  • Online demo
  • Testimonials
  • Design philosophy
  • Free & open source
  • Terms of service

Downloads

  • Latest releases
  • Skins
  • Plugins
  • Language packs

About us

  • About us
  • Contact

Webhosting Guide

  • Web hosting blog
  • Best web hosting
  • Cheap web hosting
  • Green web hosting
  • Hosting with SSH
  • VPS hosting
  • Dedicated servers
  • Reseller hosting
  • Int'l: UK / France

Docs & Support

  • Online manual
  • Forums
  • Hire a pro !

Other

  • Adsense
  • Press room
  • Privacy policy

Stay in touch

  • GitHub
  • Twitter
  • Facebook
  • LinkedIn
  • News blog
  • RSS feed
  • Atom feed

Founded & Maintained by François Planque