custom_conf_save and custom_conf_load

Since version 4.1.0

Tags {custom_conf_save} and {custom_conf_load} allow to save and load any type of configuration data inside the template. This is useful when developer wants to use the same template with slightly different parameters for different sections. The configuration data is bound to the section object and when object is displayed using customized template the appropriate configuration values are used.

{custom_conf_save}

Parameters

  • id - section ID. If object ID is not defined then current page ID is used.
  • <parameter1> - custom parameter name
  • <parameter2> - custom parameter name
  • ...

{custom_conf_load}

Parameters

  • id- section ID. If object ID is not defined then current page ID is used.
  • name - variable name where the returned data is saved. Default value is "custom_conf".

Example:

{* Configuration form for the site editors *}

{if $in_editor} 
   {* save data *}
   {if $smarty.get.save}        
       {custom_conf_save id=$id sort_by=$smarty.get.sort_by} 
   {/if} 
   {* load data *}
   {custom_conf_load id=$id name="tpl_conf"} 
   <form name="custom_conf_vars" action="{$self}" method="GET">
       <input type="hidden" name="save" value="1">
       <input type="hidden" name="id" value="{$id}">

       Sort by: <input type="text" name="sort_by" value="{$tpl_conf.sort_by}"> <input type="submit" value="Save">
   </form>
{/if}

{* Use configuration data in public view *}
{custom_conf_load id=$id name="tpl_conf"} 
Saved configuration value is: {$tpl_conf.sort_by}