Skip to the content
Documentation
Help Start
Reading in:
  • German: 9,059 of 9,059 pages
About the help in other languages
All help pages

View modes for builders

A view mode is one way of drawing content - full page, line in a list, embed in rich text. The modes the kernel ships, how a page and a list choose one, adding your own mode, and which modes are cached.

Download as PDF

Address: https://doc.exponential.earth/exphelp/viewer/help/extension-development/part-2-builder/view-modes-for-builders.md

On this page

View modes for builders

Part 2, chapter 12. The same article is drawn differently on its own page, in a list of news, and when an editor embeds it in another article. Each of these is a view mode, and each has its own template node/view/<mode>.tpl, which overrides can replace per class. This chapter shows the modes and how to add your own.

The modes the kernel ships

The standard design has one template per mode in design/standard/templates/node/view/:

ModeUsed for
fullthe page of a node: /content/view/full/<node> and every URL alias
lineone entry in a list
listitema short list entry
embedan object embedded in rich text as a block
embed-inlinean object embedded inside a line of text
sitemap, search, thumb, text, text_linked, toolline, plainspecial lists and outputs
print, pdf, execute_pdfprint and PDF output

Your design and your extensions can add more.

How a page chooses its mode

The address carries it: /content/view/<mode>/<node>. A URL alias is the full view. In templates, lists choose the mode of each item:

{def $children = fetch( 'content', 'list', hash( 'parent_node_id', $node.node_id, 'limit', 10 ) )}
{foreach $children as $child}
    {node_view_gui content_node=$child view='line'}
{/foreach}

node_view_gui draws a node in a mode, through the override system, so a line override for articles applies here automatically. content_view_gui content_object=$object view='embed' does the same for an object without a location.

Adding your own view mode

Say a front page should show teasers with a picture: a mode called teaser.

  1. Create the template for the mode, in your design: extension/mysite_design/design/mysite/templates/node/view/teaser.tpl

    <div class="teaser">
        <h3><a href={$node.url_alias|ezurl}>{$node.name|wash}</a></h3>
    </div>
  2. Give classes their own teaser where needed, with overrides on Source=node/view/teaser.tpl (see Override conditions).

  3. Use it: {node_view_gui content_node=$child view='teaser'}.

  4. Clear the template override cache (new files): php bin/php/ezcache.php --clear-id=template-override,template.

No setting is needed for a mode used only from templates. Two lists mention modes for other purposes:

SettingPurpose
content.ini [VersionView] ViewModes[]the modes the version preview of the administration offers (content/versionview)
content.ini [embed] AvailableViewModes[] and [embed-inline]the modes the online editor offers for embeds

Caching and view modes

Full pages are kept in the view cache. Which modes are cached is set in site.ini [ContentSettings]:

CachedViewModes=full;sitemap;pdf

A mode you add for pages that people open by address (for example /content/view/print/<node>) can be added there. Lists drawn inside a cached page are part of that page's cache. The rules for clearing the view cache are in Caching and templates.

Variables in a view mode template

VariableWhat it is
$nodethe node being drawn
$object$node.object, in content_view_gui the object
$view_parametersthe unordered parameters of the address (/(offset)/20) in a full view
$persistent_variablevalues a full view template sets for the pagelayout

Become an Exponential Partner

Partners share their information, provide funding, contribute back and develop the products with us, and that is how Exponential grows. A partner website and dashboard are planned for mid-2027: please become a partner today to speed up our growth rate and land new features faster.

Something wrong on this page? Report an error

Documentation license

This documentation is free documentation, licensed under the GNU Free Documentation License 1.3 or later.

Exponential Copyright © 1998-2026 Exponential Foundation and 7x