Learning: Dealing with static strings or ids within template files using custom settings files

Description

One eZ Publish best practice is storing static strings or ids as settings variables loaded in templates instead of storing static strings or ids within templates.

You should review your template files and move these static strings or ids into a settings file and make reference to the custom settings variables you define.

Example

This example should show clearly a basic example of how to store your custom variable contents within a settings file and access them in a template.

Setting

File: s ettings/override/example_com.ini.append.php

<?php /* #?ini charset="utf-8"?
 
[CustomNodeIDs]
NodeName001=42
NodeName002=84
NodeName003=11
ClassIdentifier=article
 
 
*/ ?>

Template

File: design/standard/templates/pagelayout.tpl

{def $node_name_001 = ezini( 'CustomNodeIDs', 'NodeName001', 'example_com.ini' )}
{if is_set( $node_name_001 )}
    [...display something...]
{else}
   [...display something else...]
{/if}

Reference