Stacks API

Come build with us.
Stacks API v6 for Stacks 2.5


  <   Templates Variable Reference


Conditional Display

%[if edit]% %[endif]%

This content is open source. You can edit it and submit a pull request on GitHub.
This page is generated from this file.


© . YourHead Software all rights reserved.

Conditional Display

%[if edit]% %[endif]%

Available: Stacks API v2

Usage

%[if edit]%  
    any content
%[endif]%  

or

%[if !edit]%  
    any content
%[endif]%  

Description

Enable content specifically for Edit Mode or specifically for Preview/Publish Mode.

Some content is not appropriate for display in Edit mode and other content is not appropriate for being published. You can limit the display of the content to a specific mode by using conditionals. You can use conditionals in any type of template (HTML, CSS, JS, etc.). Using a conditional to disable the display of certain elements with CSS is a good way to keep the user focused on the content that needs to be edited.

Warning: Do not place conditionals around editable content or containers (i.e. don't wrap %slice%, %text%, or %html% in a conditional.

Example 1: disable fancy CSS in edit mode for speed.

#%id% .fancyStuff {  
  %[if edit]%  
    display:none;  
  %[endif]%

  %[if !edit]%  
    display:block;  
  %[endif]%  
}  

Example 2: enable some HTML only for preview and publish

%[if !edit]%
  <span>This will not appear in edit mode!</span>
%[endif]%
© . YourHead Software all rights reserved.