Documentation

Learn to dance with the Banana!

Custom Variables

Custom variables allow you to create variables that can be re-used throughout your pages and views.

Creating a Custom Variable

  • Open the "wiki/config/custom_variables.php" file.
  • Add new entries into the array.
    • The key is the variable name.
    • The value is the output of the variable.
  • Place variables on any page using the standard double curly bracket syntax: {{ my_variable }}
  • As with many other features in the program, everything is language based, so when creating variables, place them with the correct language array (see example below)

Example

Edit custom_variables.php

Add a custom variable to the custom_variables.php page as follows:

array(
    'en' => array(
        'my_custom_variable' => 'This is the content of my custom variable that will show up on my page when I add the "my_custom_variable" variable to it.',
    ),
);

Page Content

Within your page, you can now use that variable:

# My Cool Page

Here is where the text will appear: {{ my_custom_varaible }}

Pretty cool eh?

The rendered output being:

<h1>My Cool Page</h1>

<p>Here is where the text will appear: This is the content of my custom variable that will show up on my page when I add the "my_custom_variable" variable to it.</p>

<p>Pretty cool eh?</p>

Important Notes

  • When creating variables, be sure not to overwrite standard variables used throughout the program.
  • If your variable's content has aspostrophies, make sure you escape them using a backslash. Example:
array(
    'en' => array(
        'my_custom_variable' => '(Jon\'s Example).',
    ),
);

Last modified 2 years ago.