Slots

Slots are in layout templates manageable areas, where the user can insert content elements.

 

 

Just use this Smarty-code to insert a slot in a position you want:

 

{slot id="<id>" name="<name>"}

 

Important: Make sure that the <id> is unique on each slot within one layout. For good practice you should use the same <id> for the same slots in different layouts, so that the user see his saved contents on the same or almost same position when he change to another layout.

 

It is also possible to define own attributes. You can access your own and the official attributes via kryn::$slot and {$slot}.

  • id
    All content elements inside this slot will be saved under this id (ak. box-id).
  • name
    Gives the slot a title for better understanding for what this slot stand for.
    Multilanguage possible - example:

    {slot id="1" name="[[Main content]]"}

 

Optional attributes

  • default="<defaultContentTemplate>"
    Defines a default content template file. For example you can define th_myTheme/content_withBorder.tpl, so that this template will automaticaly be choosen if a user inserts a new element to this slot. 
  • assign="<assignName>"
    If you define a template variable, then this slot will not be printed to the client, but will be saved in the specified assignName. You can access this content via {$assignName}.
    Note
    : Anyhow, this creates a manageable slot in the administration! Use {if !$admin} if you do not want that this slot appears in the administration.
  • css="<additionalCssForWYSIWYG"
    This includes additional css files for the WYSIWYG. More informations in the theme WYSIWYG article.

 

Read attributes and other informations

If you want to know all defined attributes in the current slot or want to know on which content element you currently are, then you can read kryn::$slot or {$slot}. In this variable are stored all defined attributes and following additional:

 

  • maxItems
    Defines how many content elements are in this slot.
  • isFirst
    Defines whether the current content element is the first.
  • isLast
    Defines whether the current content element is the last.
  • index
    Defines the current index.
Practical examples in a content template #1
<div class="content-element {if !$slot.isLast}content-element-borderbottom{/if}">
   {if $content.title}<h2>{$content.title}</h2>{/if}
   <div class="content-element-content" >
     {$content.content}
   </div>
</div>
Practical examples in a content template #2
<div class="content-element {if $slot.index%2}content-element-graybackground{/if}">
   {if $content.title}<h2>{$content.title}</h2>{/if}
   <div class="content-element-content" >
     {$content.content}
   </div>
</div>