#2 Working with Block Contents
Requirements
Working with Block Contents
In most cases a template will run in a context - so something prepared data for the template, which should now be visualized. These examples assume you're working with 2sxc, which let's editors work with content - and your template only needs to visualize it. The current content item (if it's just one) is always available on the variable called Content
. It's a dynamic
object, so you can just type things like @Content.FirstName
to access the properties.
The samples can differ based on your Razor base class or if you're running an old version.
Switch to Strong-Typed (2sxc 17.06+) Switch to Typed (2sxc 16+) Switch to Dynamic (Razor14 or below)
Switch to Strong-Typed (2sxc 17.06+) Switch to Typed (2sxc 16+) Switch to Dynamic (Razor14 or below)
Show Entity Values from the current Data
Showing values from Data (aka. Entities) is very easy. Normally they are accessed through Item (new Razor) or DynamicEntity (older Razor) objects.
Work with Content Items - MyItem
MyItem is the object which contains the first thing added by the editor on the current block.
#2 Working with Block Contents