Home » Documentation » Using Templates
This chapter targets web site managers that will be using templates to implement the HTML design in a Scensum installation. Before you read this chapter it’s recommended that you read Using Site Structure.
Block vs. Component
To create content or business logic on a site Scensum supports blocks and components.
Blocks are placed in the areas defined by a content page’s page template. Using blocks and the site structure admin interface in back office a content manager can rearrange order and layout, modify and display or remove content for a web page (see Using Site Structure).
A component is added directly to a template and is thus not manageable from the site structure administration in back office.
Template
A block (or component) normally has a template to render some user interface.
A template is made up of template fragments, model functions and in some cases settings. Depending on the block type the template will have different functions and fragments to work with. A cart component might for instance have a cart item row fragment and cart summary variable while a rich text block might just have a content fragment.
A template uses HTML and Scensum variables and conditions from the template fragments to render content.
Each template has a head section that can be used to add code to the head tag of the HTML document. The head section is applied aggregating head content to the head tag, e.g. a master page’s, content page’s and blocks head content will all be added to the head tag.
Functions
Functions are divided into variables and conditions.
A variable is a model attribute, a value of the object that you can display when rendering the object, e.g. [Block.Title] or [Product.Price]. A variable could also be a fragment attribute that is used to call other fragments, e.g. [Iterate:Product]
A function is always encapsulated by hard brackets and if the current template fragment defines the specified function it will in runtime replaces it with the attribute value. This means that there will be “reserved words” that is used will be replaced with a model attribute.
A condition is a Boolean evaluation that can be used to render different output depending on a condition result, e.g. User.IsSignedIn. A condition always has a true and a false option with the syntax “[if <model attribute>] [Else] [End if]”. The template engine will evaluate the condition and include what’s in front of the else-keyword if the evaluation returns true and what’s after the else-keyword if it evaluates false.
Include
When you feel that you are writing the same piece of template code over again it might be a good idea to break it out into a shared piece of code. This is called an “Include” in Scensum. The code snippet can be accessed by the includes system name using the syntax [include("<system name>”)].
You can use includes from all template fragments but the best utilizations are when you are using the same template code in multiple places or when you need to break a large template into manageable chunks, e.g. perhaps in a condition statement.
As the include is pulled into the normal template on rendering it can utilize the same template functions as the fragment in which it is used.
Components
While blocks are added and managed in the site structure, components are added directly to the template. Any component can be added to any template and any template fragment. Adding a component to a template will cause the template engine to pull in the component and render it at the specified place in the template.
A component is added by the syntax [Component("<component name>")] or depending on the current component there might be multiple input parameters that needs to be defined, e.g. [Component("NavigationTree", "TemplateId=?", "StartFromId=?", "StartFromCommonName=?", "StartFromLevel=?", "AlwaysExpanded=?")].
Theme
Once the templates have been created they can be defined as a default setup in Scensum using themes. In Scensum there is always a default theme that cannot be deleted. The theme defines a default template for each block type or component. If not specified when creating a block or component the current themes default template will be used.
A theme can be overridden per block or by creating an overriding theme. The overriding theme can choose to only override one, some or all default templates. The theme is applied to a channel to define the channels default design.