A "Content Block" is a piece of content, similar to a post (with text, inline images, an owner, a revision history etc.) that can be included in other places of a site.
Where to use a content block
A content block could be included in places like this:
- Included as a section of a home page, like "About Us" or "Disclaimer" or a pricing table etc. A home page could have many sections (possibly with photo backgrounds) and people could scroll down, down, down…
- Displayed in a widget anywhere… See the Content Block Widget
- Included in another post. For example if we have a "WARNING: blah blah blah" paragraph that needs to be repeated over and over in a book/manual or a disclaimer that needs to be added to every post of an investment related blog… It could be written once and any update would update all affected pages. This can be achieved with a short tag like
[include:123](using the content block ID) or
[include:slug](using the content block slug). See: [include:] Short Tag. Note: the content block will be rendered with its own renderer plugins which may be different from the parent post.
Differences between content blocks and regular posts
- Content blocks have a Slug to identify them but they can never be called by themselves through an URL. They can only be embedded in something else.
- Content blocks have no comments.
- Content blocks have no category/chapter. (internally they are stored in the default category)
- No excerpt
- No Goal tracking
- No notifications
- No <title> and no <meta> tags
Note: content blocks may include other content blocks.
If b2evolution detects a loop it will display an error on screen like "Content inclusion loop detected. Not including "%s"."
Custom fields and other short tags
If you are using a content block as a pattern displaying Custom Fields, you probably want to display the fields of the caller, not the fields of the content block itself…
So, if you do not want
[field:x] to resolve in the content-block, you can change it to
[-field:x]. Then it will resolve one level higher.
If you include a content block which itself includes a content block, etc. , you can control how many levels higher up you want the field to resolve by using
This also works for other short tags like
[-fields] , [-parent:…], etc.