Loading...
 

Dynamic variables


The dynamic variable feature allows you to add some content once, assigning it to a variable, and then you can use it dynamically throughout all your Tiki site by calling the variable name surrounded by percentage characters (%). Like this:

Copy to clipboard
%variable14%


So to use, just click on the text in the box below (you need to be logged in):

strong


The permission tiki_p_edit_dynvar must be given to the group. On the current site tiki_p_edit_dynvar has been given to Anonymous group. The box above is just to help you find the text. Dynamic variables can be used in a sentence. For example, " strong " is the current value.

This can be useful for contact name, phone number, etc. to be used throughout a Tiki site. If you have a multilingual Tiki, you can use dynamic variables for strings of text which are the same in all languages.

This feature is different than Dynamic Content.

Usage

(1) Create a new variable, by calling it

Copy to clipboard
%variable15%


This will show the text:

NaV

which indicates that this is "Not a Variable" yet. (Please note in newer Tiki versions it shows "No value assigned" instead.) If you pass the mouse pointer over it, if will say "Click to edit dynamic variable: variable15" as follows:

Image


(2) Click on the Nav link

Image


Then you can add the content for that dynamic variable. Click on the update variable link, and you are done.

1.1.2. Limitations

If you create a variable containing some code which produces something "invisible", you cannot edit it later then because there's nothing to click and no admin GUI to administer them later. If you want to edit those dynamic variables, you will have to edit them directly in the database table tiki_dynamic_variables where they are stored.

1.1.3. Examples

Example 1

Example:
You might use dynamic variable to clear the specification to float images over the text through a div plugin call, and without allowing users to write html code on wiki pages.

You can create a new variable called:

Copy to clipboard
%clear%


Then add this as content:

Copy to clipboard
<br class="clear" />


This way, you can just write %clear% after each paragraph where you want to ensure that the previous image doesn't overlap with the following headings, etc.

For example:

In the following example "2.1. First section 2.2 Second section 2.3. Third section" please do not mind the pictures, but mind the position of the text above and besides the pictures:

1.1.3.1. First section

Image    
This paragraph shows nothing more than a short paragraph, without the %clear% dynamic variable being used at the end, so that the next section overlaps.

1.1.3.2. Second section

Image    
This paragraph shows nothing more than a short paragraph overlapped to the left space from the previous floating image. However, after this paragraph we have added the %clear% dynamic variable, so that the next section don't overlap.


1.1.3.3. Third section

Image    
This paragraph shows nothing more than a short paragraph, which is not overlapped to the remaining space to the right of the previous floating image, because the %clear% dynamic variable was used above it.


see the Code
Copy to clipboard
!!!!# First section {DIV(float=>left)}{img src=display1359 width=300 }~hs~~hs~~hs~{DIV}This paragraph shows nothing more than a short paragraph, without the %clear% dynamic variable being used at the end, so that the next section overlaps. !!!!# Second section {DIV(float=>left)}{img src=display1359 width=300 }~hs~~hs~~hs~{DIV}This paragraph shows nothing more than a short paragraph overlapped to the left space from the previous floating image. However, after this paragraph we have added the %clear% dynamic variable, so that the next section don't overlap. %clear% !!!!# Third section {DIV(float=>left)}{img src=display1359 width=300 }~hs~~hs~~hs~{DIV}This paragraph shows nothing more than a short paragraph, which is not overlapped to the remaining space to the right of the previous floating image, because the %clear% dynamic variable was used above it. %clear%


This variable will be "invisible" on the actual wiki page.
So, if you want to edit the content of this variable afterwards, you need to edit it directly at the MySQL table tiki_dynamic_variables.

Example 2

You can create "custom syntax", e.g. for the "big" HTML tag:

Copy to clipboard
%big_begin%This is Big%big_end%


Result:
This is Big

Example 3

Similarly for the "small" HTML tag:

Copy to clipboard
%sm_begin%This is small%sm_end%


Result:
This is small

1.1.4. Usage notes

1. Only lowercase letters, numbers and underscores appear to work in variable names

Copy to clipboard
%Test1% Does not work %Test 1% Does not work %test% Works %test 1% Does not work %Test_1% Does not work %Test% Does not work %test1% Works %test_variable% Works


2. Some wiki syntax works within the variable content (like ((wiki links))) and some does not (like %%% embedded newlines)

3. Some html content works
Copy to clipboard
like <br /> for newlines


4. Here is a sample SQL UPDATE script for a dynamic variable that contains wiki links:

Copy to clipboard
UPDATE tiki_dynamic_variables SET data = "<br><h3>Links</h3><br>((Perl Arrays))<br>((Perl Variables))<br>" WHERE name = "perl_wiki_links"

Some Dynamic Variables Used on This Site

In the following table you can right click and "Inspect" element to see the actual rendered code:

Variable Name Value Actual Variable as rendered
%big_begin% <big>
%big_end% </big>
%clear% <br class="clear" />
%sm_begin% <small>
%sm_end% </small>
%userguide% &structure=Tiki+User+Guide {PARAM(name="structure")} {ELSE}{redirect page="{{page}}&structure=Tiki+User+Guide"}{PARAM}
%variable14% Hello Tiki! Testing 3 2 1! strong
Unable to load the jQuery Sortable Tables feature.

Show a list

List Slides