In Open CSP 2.0 the default sidebar was added, this allows you to have sidebars without having to create custom sidebar templates for each class definition. There are some customization options built into the default sidebar as well. It is recommended to use these customization options when possible and to only create fully custom sidebar templates when absolutely necessary, as the fully custom sidebar templates require a lot more maintenance work when for example some parserfunctions get deprecated or changed. This document describes the various customization options. Note that it is also possible to configure class definitions to use custom templates for the sub-header and footer components, however these do not have extensive customization options like the sidebar and are therefore not described further in this document.

Parameters and formfield/display templates

  • Edit parameters on a class definition page, to configure what will show up on your sidebar.
  • Note that the parameter configuration is also used for setting properties, but you can use "(none)" as property name value if you don't want to set a property.
  • Only the "parameter name" field is required. When you only fill this, you will get default text fields in the sidebars.
  • Choose a displayTemplate to configure how a parameter is displayed in the view tab of the default sidebar.
  • Choose a formfieldTemplate to configure what type of form field is used in the edit tab of the default sidebar.
  • DisplayTemplate and formfieldTemplate can both be set to "(none)" to not have a parameter show up in respectively the view and edit tabs of the default sidebar.

Custom formfield/display templates

  • It is possible to add custom template names in the displayTemplate and formfieldTemplate fields.
  • All fields that are filled for a parameter will be passed to the templates so they can be accessed through template parameters there. For example you can use {{{allowedValues|}}} in a formfieldTemplate. It might be useful to look at the csp-data slot of the class definition to see all of the parameters.
  • The values of parameters on a content page are also passed to the display/formfield templates as the "value" parameter.
  • In a display/formfield template you cannot access values of other parameters directly, but you can do this by using {{#invoke:CspFunctions|getParentArg|$pageData}}, which will return the $pageData parameter that is used in Template:Csp default sidebar (and contains an ArrayFunctions export with slotdata of the page).
  • It is possible to add fields to the json data in the csp-data slot that cannot be filled through the parameters form. For example Open CSP 2.0 does not yet include the option to specify a placeholder for your formfields, but you can add placeholder to the json data and then use {{{placeholder|}}} in a custom formfieldTemplate.

Custom sidebar template where you are adding to the default sidebar

In many cases you won't necessarily want to replace the default sidebar, but you may want to add another card above or below it with additional functionality. It is possible to use the default sidebar within a custom sidebar template. For example like the following code snippet:

{{Csp default sidebar
|$pageData={{{$pageData|}}}
|$classData={{{$classData|}}}
}}


{{Csp sidebar tabs
|id=another-card
|canEdit=yes
|closeButton=
|title=Another card
|subTitle=Below the default sidebar
|view=<div class="card-body">viewtab content</div>
|edit=<div class="card-body">edittab content</div>
}}

Fully custom sidebar template

In a fully custom sidebar template you can do anything you want. You will still get the $pageData and $classData parameters passed to this template so you can use those. The following is an example of custom sidebar code that will produce a sidebar similar to the default one, perhaps this will give you some ideas for what's possible:

<div class="tab-content"><!--
--><input type="radio" id="sidebar-view" name="toggle-sidebar" checked="checked" class="d-none sidebar-view" /><!--
--><div class="card sidebar-view-tab">
<div class="card-header">{{#ifeq:{{#ifingroup:user |{{#if:{{#urlget:veaction}}{{#urlget:action}}||yes}} }}|yes |<span style="float:right"><label for="sidebar-edit" class="btn btn-secondary">Edit</label></span>}}
<b class="d-block">{{#af_get:{{{$pageData}}}|csp-base-props|Base properties|1|Class|_text}}</b>
{{#af_get:{{{$pageData}}}|csp-base-props|Base properties|1|Title|_text}}
</div><!-- end of .card-header -->
<div class="card-body">
{{Csp sidebar item
|Label=Title
|Value={{#af_get:{{{$pageData}}}|csp-base-props|Base properties|1|Title |_text}}
}}{{Csp sidebar item
|Label=TextInput
|Value={{#af_get:{{{$pageData}}}|csp-class-props|Csp class properties|1|TextInput |_text}}
}}{{Csp sidebar item
|Label=TokenInput
|Value={{#af_get:{{{$pageData}}}|csp-class-props|Csp class properties|1|TokenInput |_text}}
}}{{Csp sidebar item
|Label=AskTokenInput
|Value={{#af_join:{{#af_map:{{#af_split:{{#af_get:{{{$pageData}}}|csp-class-props|Csp class properties|1|AskTokenInput |_text}}|,}}|@@|[[{{{@@}}}|{{#show:{{{@@}}}|?Title}}]]}}|<br>}}
}}{{Test date display
|Name=DateInput
|Value={{#af_get:{{{$pageData}}}|csp-class-props|Csp class properties|1|DateInput |_text}}
}}
{{Csp sidebar item
|Label=DateInputTwo
|Value={{#if:{{#af_get:{{{$pageData}}}|csp-class-props|Csp class properties|1|DateInputTwo |_text}} |{{#time: j M Y H:i |{{#af_get:{{{$pageData}}}|csp-class-props|Csp class properties|1|DateInputTwo |_text}} }} }}
}}{{Csp sidebar item
|Label=TextInputTwo
|Value={{#af_get:{{{$pageData}}}|csp-class-props|Csp class properties|1|TextInputTwo |_text}}
}}{{Csp sidebar item
|Label=CheckboxInput
|Value={{#af_get:{{{$pageData}}}|csp-class-props|Csp class properties|1|CheckboxInput |_text}}
}}{{Csp sidebar item
|Label=TextAreaInput
|Value={{#af_get:{{{$pageData}}}|csp-class-props|Csp class properties|1|TextAreaInput |_text}}
}}{{Csp sidebar item
|Label=NumberInput
|Value={{#af_get:{{{$pageData}}}|csp-class-props|Csp class properties|1|NumberInput |_text}}
}}{{Csp sidebar item
|Label=SelectInput
|Value={{#af_get:{{{$pageData}}}|csp-class-props|Csp class properties|1|SelectInput |_text}}
}}{{Csp sidebar item
|Label=TokenMultipleInput
|Value={{#af_get:{{{$pageData}}}|csp-class-props|Csp class properties|1|TokenMultipleInput |_text}}
}}<!--

--></div><!-- end of .card-body -->
</div><!-- end of .card 

-->{{#ifeq:{{#ifingroup:user |{{#if:{{#urlget:veaction}}{{#urlget:action}}||yes}} }}|yes |<!--
--><input type="radio" id="sidebar-edit" name="toggle-sidebar" class="d-none sidebar-edit" /><!--
--><div class="card sidebar-edit-tab"><!--
--><div class="card-header"><span style="float:right"><label for="sidebar-view" class="btn btn-secondary" >Close</label></span>
<b class="d-block">{{#af_get:{{{$pageData}}}|csp-base-props|Base properties|1|Class|_text}}</b>
{{#af_get:{{{$pageData}}}|csp-base-props|Base properties|1|Title|_text}}
</div><!-- end of .card-header -->
<div class="card-body">
<form><!--

// _edits: no edit when formfieldType is set to "(none)"
--><_edit target="{{PAGEID}}" template="Base properties" formfield="Title" mwslot="csp-base-props" />
<_edit target="{{PAGEID}}" template="Csp class properties" formfield="TextInput" mwslot="csp-class-props" />
<_edit target="{{PAGEID}}" template="Csp class properties" formfield="TokenInput" mwslot="csp-class-props" />
<_edit target="{{PAGEID}}" template="Csp class properties" formfield="AskTokenInput" mwslot="csp-class-props" />
<_edit target="{{PAGEID}}" template="Csp class properties" formfield="DateInput" mwslot="csp-class-props" />
<_edit target="{{PAGEID}}" template="Csp class properties" formfield="DateInputTwo" mwslot="csp-class-props" />
<_edit target="{{PAGEID}}" template="Csp class properties" formfield="TextInputTwo" mwslot="csp-class-props" />
<_edit target="{{PAGEID}}" template="Csp class properties" formfield="CheckboxInput" mwslot="csp-class-props" />
<_edit target="{{PAGEID}}" template="Csp class properties" formfield="TextAreaInput" mwslot="csp-class-props" />
<_edit target="{{PAGEID}}" template="Csp class properties" formfield="NumberInput" mwslot="csp-class-props" />
<_edit target="{{PAGEID}}" template="Csp class properties" formfield="SelectInput" mwslot="csp-class-props" />
<_edit target="{{PAGEID}}" template="Csp class properties" formfield="TokenMultipleInput" mwslot="csp-class-props" />
<_edit target="{{PAGEID}}" template="Csp class properties" formfield="TestNoDisplay" mwslot="csp-class-props" />
<!-- end of _edits

// form fields
-->{{Csp sidebar item
|Label=Title
|Value=<input type="text" name="Title" class="form-control" required="required" value="{{#af_get:{{{$pageData}}}|csp-base-props|Base properties|1|Title|_text}}" />
}}
{{Csp sidebar item
|Label=TextInput
|Value=<input type="text" name="TextInput" class="form-control" required="required" value="{{#af_get:{{{$pageData}}}|csp-class-props|Csp class properties|1|TextInput|_text}}" />
}}
{{Csp sidebar item
|Label=TokenInput
|Value=<_token id="token-{{lc:{{anchorencode:TokenInput}} }}" name="TokenInput[]" class="form-control" allowclear selected="{{#af_get:{{{$pageData}}}|csp-class-props|Csp class properties|1|TokenInput|_text}}" options="Ay,Bee,Cee" />
}}
{{Csp sidebar item
|Label=AskTokenInput
|Value=<_token id="token-{{lc:{{anchorencode:AskTokenInput}} }}" name="AskTokenInput[]" class="form-control" required="required" multiple="multiple"  input-length-trigger="1" query="[[Class::+]][[Title::!!!]](limit=999)(returntext=Title)" >
{{#af_join:{{#af_map:{{#af_split:{{#af_get:{{{$pageData}}}|csp-class-props|Csp class properties|1|AskTokenInput|_text}} }} |$value|<option value="{{{$value}}}" selected="selected">{{#show:{{{$value}}}|?Title}}</option>}}|\n}}
</_token>
}}
{{Test date formfield
|Name=DateInput
|Value={{#af_get:{{{$pageData}}}|csp-class-props|Csp class properties|1|DateInput|_text}} 
}}{{Csp sidebar item
|Label=DateInputTwo
|Value=<input type="datetime-local" name="DateInputTwo" class="form-control" value="{{#af_get:{{{$pageData}}}|csp-class-props|Csp class properties|1|DateInputTwo|_text}}" />
}}
<div class='alert alert-danger'>No template defined in parameter definitions</div>{{Csp sidebar item
|Label=<label for="checkbox-{{lc:{{anchorencode:CheckboxInput}} }}" >CheckboxInput</label>
|Value=<input type="hidden" name="CheckboxInput" value="" />
<input type="checkbox" id="checkbox-{{lc:{{anchorencode:CheckboxInput}} }}" name="CheckboxInput" value="Yes" checked="{{#ifeq:{{#af_get:{{{$pageData}}}|csp-class-props|Csp class properties|1|CheckboxInput|_text}} |Yes|checked}}" />
}}
{{Csp sidebar item
|Label=TextAreaInput
|Value=<input type="textarea" name="TextAreaInput" class="form-control" >{{#af_get:{{{$pageData}}}|csp-class-props|Csp class properties|1|TextAreaInput|_text}}</input>
}}
{{Csp sidebar item
|Label=NumberInput
|Value=<input type="number" name="NumberInput" class="form-control" value="{{#af_get:{{{$pageData}}}|csp-class-props|Csp class properties|1|NumberInput|_text}}" />
}}
{{Csp sidebar item
|Label=SelectInput
|Value=<select name="SelectInput" class="form-control" allowclear selected="{{#af_get:{{{$pageData}}}|csp-class-props|Csp class properties|1|SelectInput|_text}}" options="Alpha,Bravo,Charlie" />
}}
{{Csp sidebar item
|Label=TokenMultipleInput
|Value=<_token id="token-{{lc:{{anchorencode:TokenMultipleInput}} }}" name="TokenMultipleInput[]" class="form-control" multiple="multiple" selected="{{#af_get:{{{$pageData}}}|csp-class-props|Csp class properties|1|TokenMultipleInput|_text}}" options="Alpha,Bravo,Charlie" />
}}
{{Csp sidebar item
|Label=TestNoDisplay
|Value=<input type="text" name="TestNoDisplay" class="form-control" value="{{#af_get:{{{$pageData}}}|csp-class-props|Csp class properties|1|TestNoDisplay|_text}}" />
}}
<!-- 

--><div class="text-right">
<label for="sidebar-view" class="btn btn-secondary">Close</label>
<input type="submit" value="Save" class="btn btn-primary" />
</div>
</form>
</div><!-- end of .card-body -->
</div><!-- end of .card -->
|}}<!-- end of #ifeq @allow sidebar edit == yes -->
</div>