Tags as variables

By MatthewDaveyMatthewDavey

You can use tags as variables on a page, so then you can use pages like database records or a ticket system.

You first create a category template.

For example a category template for the category called myvariables would be:

myvariables:_template

The code for the template would be:

+ Tags as variables

The Tags are: %%tags%%

Here is an example of them formatted in a page:

 [[include myvariables:%%page_name%% %%tags%%]]

%%content{1}%%

Then create the page in the myvariables category. For example create one called page1. This page would be:

myvariables:page1

Some example code for the page could be:

=====

+ {$_var3} {$_var2}

{$_var1} is a {$_var2} of some {$_var3}'s
  • The ===== is to create a content section.

Then on that page, create the variables in the tags section by adding the following tags:

_var1=this| _var2=test| _var3=variable|

  • The underscore is to hide the tags from modules such as ListPages.
  • The | must be the last character of each variable to tell the include module to separate the variables.

Please note: Tags are converted to all lowercase.

The Result:


Tags as variables

The Tags are: _var1=this| _var2=test| _var3=variable

Here is an example of them formatted in a page:

variable test

this is a test of some variable's


To change the variables to have the first character capitalized use the [[span]][[/span]] tags.
(The text-transform style type can have: capitalize, uppercase, lowercase, none.)

The code would then be:

=====
[[span style="text-transform:capitalize"]]
+ {$_var3} {$_var2} [[/span]]

[[span style="text-transform:capitalize"]]
{$_var1} [[/span]] is a {$_var2} of some {$_var3}'s

The Result:


Tags as variables

The Tags are: _var1=this| _var2=test| _var3=variable

Here is an example of them formatted in a page:

Variable Test

This is a test of some variable's



Thanks to tsangk for this great snippet: conditional-blocks


text above inserted with:

[[include :snippets:if START |unique=1|type=equal|var1=%%name%%|var2=conditional-blocks]]
**##red|Thanks to tsangk for this great snippet:##** [[[code:conditional-blocks]]]
[[include :snippets:if END]]



Other snippets posted by MatthewDavey


Rate this solution

If you think this solution is useful — rate it up!

rating: +8+x
Add a New Comment
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License