Syntax

From ActionApps Documentation

Jump to: navigation, search

Contents

Curly Brackets Syntax Introduction

Note that there are two different ways of accessing the actual value of a field in your design templates. This reference explains the curly bracket syntax, which we encourage you to use extensively, as it's somewhat cleaner. The discussion about the actual differences can be found at the beginning of the Designing_Output_Templates chapter. The {} syntax, also sometimes called in-line alias definition marks up a special action that needs to be taken when rendering the output of a design template. The action is:

Evaluate the expression between { and }, and substitute the whole string including the brackets with the actual result of the evaluation.

Complicated as it may sound, the simplest example which is at the same time the most common usage is this

{headline........}

which simply says:

  • lookup the value of headline........ - that's the evaluation bit
  • and print it - that's the substitution bit

You will see below that an expression enclosed in {} can contain another (nested) expression. For interpreting and designing more complicated expressions correctly, you must remember that ActionApps interprets the innermost expression first.

Below is the list of all the expressions you can use. The developers appologize for the inconsistency in paramater separators - sometimes :, sometimes ?, sometimes ( . Eh...

{(....)} - Syntax for deffered evaluation

This way you are able to pass {..} any aa_expressions to any function instead of using just aliases there.
Example:

{item:6625:{(some text {headline........}...etc.)}}

{inputvar} - Reading names of fields

Prints out the input field of the specified field, exactly as it is specified in Slice Admin
For example, when I want to design a completely new Input Form, I create a new view of this type and, by using the {inputvar} directive, print out individual input fields (checkbox,radio,textarea,..)
Useful when we need two or more input fields on one line of the layout, let's say the given name and the family name, we need to use

Syntax:

{inputvar:input}

Example:

{inputvar:first_name......}{inputvar:surname.........}

{formbreak} Dividing input forms

This is ment to divide the input form into several parts, one possibility is to display the form in 'TABS'. Be careful, as you need to make a complete list of all parts at the beginning of the form.

Example:

<form>
{formbreak:general:addressing:notes}
<input type=text name=“name“>
<input type=text name=“middleName“>
<input type=text name=“familyName“>
{formbreak:addressing}
<input type=text name=“AddressLine1“>
<input type=text name=“AddressLine2“>
{formbreak:notes}
<textarea name=“notes“>Place notes here</textarea>
</form>


{icq} Connecting to a user

Displays a clickable image with a customized look that links to the person's chat address.

Syntax:

{icq:<user_id>[:<action>[:<style>]]}

Parameters:

user_id  - ICQ ID of the user
action   - add | message
style    - 0-26 - displayed icon type

Example:

{icq:12345678:message:1}

{skype} Connecting to a user

Functions similar to {icq}, but the image links us to skype.

Syntax:

{skype:<skype_name>[:<action>[:<style>[:<message>]]]}

Parameters:

skype_name  - skype name of the user
action      - add | call | chat
style       - add | call | chat | smallicon | mediumicon | ballon | bigclassic | smallclassic
message     - a text to display

Example:

{skype:12345:chat:balloon:Skype me}

Outputs:

<a href=“skype:12345?chat“>   [the appropriate image]  </a>

{yahoo} Connecting to a user

  • The same as the previous instant messaging directives
  • The output is similar to {skype} as it does not link to an external website, just places the ymsgr: part into the URL of the link

Syntax:

{yahoo:<yahoo_name>[:<action>[:<style>]]}

Parameters:

user_id    - yahoo name of the user
action     - addfriend | call | sendim
style      - 0-4 - dysplayed icon type

Example:

{yahoo:my_name:addfriend:1}

{fmod} Counting modulos

Example:

{fmod:1:2}

Outputs „1“ because the remainder of the division of the numbers 1 and 2 is 1. (1 / 2 = 0, remainder 1)

{cookie} Eating chocolate chip cookies all day

Syntax:

{cookie:name}

Returns the 'value of the cookie' specified by name

{now} Displaying the current time (server)

Prints the current time, as far as I am concerned it prints out the Unix timestamp (of the current date and time on the server machine)

{substr} Dividing strings

Performs a substring on the given 'string', starting at position 'start', with the 'length' specified
Syntax:

{substr:string:start:length}

length defaults to (109 -1)
!beware that the first character of the string is actually the 0th

{str_replace} Replacing substrings

Acts like the PHP function str_replace, the arguments are : search for what, replace with what, search where
Syntax:

{str_replace:find:replace_with:search}

{urlencode} Provide a 'safe' URL

Encodes the 'URL', so that there are no alphanumeric characters except the underscore (_)
Example:

{urlencode:http#://www.no-commerci.al}

Note the escape character (#) usage, so that the other part of the 'URL' doesn't seem like a second parameter to the directive

{csv} Provide 'safe' CSV

Useful when we try to export a comma-separated-values file, this directive parses the text contained in the 'field' and replaces quotes with double-quotes and \r\n with \n, so that the CSV format is maintained
Example:

{csv:abstract........}

Note that this directive does not output CSV itself, it is just used to provide the accurate format of the string, later to be used in the CSV.

{asis}

Return the 'exact' same text, as the one inserted into the database
Example:

{asis:abstract........}

Remember, that it is not the same as {abstract........}, since {abstract........} takes care about HTML/Plain text setting of the field, so the newlines are sometimes replaced by <br>. It is usefull for "Modify content..." feature of Item Manager, for example.

{htmlspecialchars} Escaping HTML chars

Outputs the string inputted, converted into an HTML-friendly format
Example:

{htmlspecialchars:„I love that dog“ is my favorite <quote> from the movie 'Me, Myself & Irene'}

Prints out:

&quot;I love that dog&quot; is my favorite &lt;quote&gt; from the movie &#039;Me, Myself &amp; Irene&#039;

Note that other conversions than these (5) are 'not' performed. See htmlspecialchars() function in PHP

{javascript} No apostrophes? No problem!

Escapes apostrophes in input string (with a backslash)
Syntax:

{javascript:string}

{striptags} Strip all tags

Strips all HTML and PHP tags from the 'string'
Syntax:

{striptags:string}

See striptags() function in PHP.

{rss} Feeding text

Replaces &nbsp; with whitespace ( ) and the amphersand (&) with &amp;
Syntax:

{rss:string}

{convert} The text encoding

Syntax:

{convert:text:from:to}

Converts the 'text' from 1 encoding to another
Example:

{convert:some_text:windows-1250:us-acsii}

{htmltoggle} HTML code for switching the divs

Creates the link text1 (or text2) and two divs, where only one is visible at a time Syntax:

{htmltoggle:<toggle1>:<text1>:<toggle2>:<text2>}

Example:

{htmltoggle:more >>>:Econnect:less <<<:Econnect is ISP for NGOs...}

Parameters:

toggle1default link text
text1HTML code displayed as default (in div)
toggle2link text 2
text2HTML code displayed as alternative after clicking on the link

The /javscript/aajslib.php3 shoud be included to the page (by <script src="">)

{aggregate} Operation across set of items (sum, average, ...)

Searches the database for id (long OR short) values and 'glues' them together to form such an aggregate, using a specified function
IDs are separated by hyphens (-)
Function values are: 'sum','avg','concat','count'

Example:

{aggregate:sum:1264897-5489421-5975546:_#RIVERANK}

Will output the total sum of cities that are near a riverbank, suppose we have a slice of Cities with the field riverbank....... containing logical values 1 or 0 according to the near-a-riverbank status of the city

Syntax:

{aggregate:function:ids_string:expression:parameter}

Expression and parameter are optional
You use no expression, when all you need is to count the values, i.e. you use the 'count' function
Parameter is used as a delimeter of values, if the 'concat' function is used and defaults to NULL, so be sure to set it, when you're using 'concat'

{ids} Get the short/long ids

Returns the ids (long ids) of all the 'fields' in the specified 'slice' that match the 'condition', appearing in specific 'order'
Syntax:

{ids:<slices>:<conds>[:<sort>[:<delimiter>[:<restrict_ids>]]]}

Example:

{ids:6a435236626262738348478463536272:d-category.......1-RLIKE-Bio-switch.........1-=-1:headine........-}

Parameters:

slicesslice id where we want to search (it is also possible to specify more than one slice in the slice parameter, in this case, separate slices by dash (-). Note that in this case, the input string of condition should be the classical „d“ condition (e.g. d-category........-=-1)
condsconditions. You can use "view" - d- format (like d-category.......1-RLIKE-Bio) or "slice" conds[] format (like conds[0][category........]=first&conds[1][switch.........1]=1).
sortordering - like publish_date.... (ascending), publish_date....- (descending)
delimiterdelimiter of the ids (default value is -, which is good for ussage in {item...}, {view...x-..} and other constructs)
restrict_idsdash (-) separated list of ids used as filter - only subset of these ids are returned

Often used together with {item..}:

{item:{ids:...}:_#HEADLINE}

{item} Display field/alias of given item

Syntax:

{item:<ids>:<aa_expression>[:<delimiter>[:<nested_top>[:<nested_bottom>]]]}

Example:

{item:8ebc541d3703e64042cc198e6d0b026c:short_id........}
{item:171055:_#HEADLINE}

Returns field or _#ALIAS___ substitution for item given by short or long id. It is possible to specify more than one ID in ids. ids should be dash "-" separated and could be in short as well as long form.
You can specify also record delimiter as fourth parameter. If not present no delimiter is used.

Example:

{item:53443-54322-53553:_HEADLINE:, }

Often used together with {ids..}, which then emulates some kind of inline views:

{item:{ids:...}:_#HEADLINE}

You can use item to display items in tree as well. In that case you will use tree representation string, just like:

 3234(3443-3678(3872-3664)-3223)-4045

Last two parameters nested_top and nested_bottom could be used for formating.

Practical examle of ussage is for example breadcrumb navigation:

 {item:{xseo1}({xseo2}({xseo3}({xseo4}))): _#HEADLINE:: <a href="_#ITEM_URL">_#HEADLINE</a> >:}

or better

 {item:{xid:path}: _#HEADLINE:: _#HEADLINK >}

However, you will be able to use it for discussions tree as well.

Tree string representation and formating

Generic tree

  -+-- 1 --+-- 2
   |       |
   |       +-- 3 --+-- 5
   |       |       |
   |       |       +-- 6
   |       +-- 4
   +-- 7
   |
   +-- 8
 represented as: 1(2-3(5-6)-4)-7-8
 printed as: 1 nested_top
             2 content
             3 nested_top
             5 content
             delimeter
             6 content
             3 nested_bottom
             4 content
             1 nested_bottom
             7 content
             delimeter
             8 content

SEO path (like for breadcrumbs - xseo1 --- xseo2 --- xseo3)

  --- 1 --- 2 --- 3
 represented as: 1(2(3))
 printed as: 1 nested_top
             2 nested_top
             3 content
             2 nested_bottom
             1 nested_bottom


Normal list of items

  -+-- 1
   |
   +-- 2
   |
   +-- 3
 represented as:  1-2-3
 printed as: 1 content
             delimeter
             2 content
             delimeter
             3 content

{next}, {previous} Next/Previous ID in list

Next/Previous item for the current item in the list - like: Syntax:

{next:<ids>:<current_id>}
{previous:<ids>:<current_id>}

Example:

{next:12324-353443-58921:353443}   // returns 58921
{next:{ids:6353428288a923:d-category........-=-Dodo}:566a655e7787b564b8b6565b}

{limit} Subset of IDs list

Allows you to get only the part of ids from the list - like: Syntax:

{limit:<ids>:<offset>[:<length>[:<delimiter>]]}

Offset and length parameters follows the array_slice() PHP function

Example:

{limit:12324-353443-533443:0:1}   // returns 12324
{limit:{ids:6353428288a923:d-category........-=-Dodo}:0:1}

{ifset} Conditional printing

If there is ANY text in 'condition', then print out the text
Syntax:

{ifset:condition:text}

Example:

{ifset:{img_height......}: height="_#1"}

{ifeq} Printing in the case of equality

If <var1> is equal to <var2>, then print <text>, else prints <else_text>. <(else_)text> could contain _#1 and _#2 aliases for <var1> and <var2>, but you can use any {} AA expression there.
Syntax:

{ifeq:<var1>:<var2>:<text>:<else_text>}

Example:

{ifeq:{xseo1}:about: class="active"}

{compare} Comparison printing

Compares two given values and outputs E,L,G, when the values are Equal, the first is Less than or the first is Greater than the second, respectively
Syntax:

{compare:Adam:Eve}

Example:

{switch({compare:{last_edit.......}:1125481998})L:less:G:more:equal}

{field} What was the name of that field?

Returns the name 'property' of the given 'field_id' in the given slice
Syntax:

{field:field_id:property:slice_id}

Note that 'property' not only defaults to name, but presently cannot be set to a different value.
Useful when you're trying to determine the correct name of the field

{dictionary} Translate words in a text

This is used when you need to, say, replace each occurence of your website 'URL' by a link to that very same 'URL'
Syntax:

{dictionary:dictionary_slice:output_text:format:conditions}

You can create "dictionary" slice, where each item will contain a word (in keywords........ field!) and url in other field (and possibly any other fields). Then you can use this "dictionary" slice in your own slice to add links to "dictionary words". You can do it by mentioned syntax where:

  • dictionary_slice is id of "dictionary slice"
  • output_text is the text, where you want to search and replace for dictionary words
  • format specifies, how to replace the keyword
  • conditions is optional parameter, where you can filter only subset of used keywords from "dictionary slice". The syntax is normal conds[] array like: conds[0][category........]='myDict'&conds[1]... (simplified as well as extended syntax)

Example:

{dictionary:4394e6117a0d66fee7cb49ffab9015d2:{_#FULLTEXT}:<a href="_#KEYW_URL">_#KEYWORD_</a>}

_#KEYWORD_ is special alias, which could not be defined in the "dictionary slice". The reason, why we use it is, that you can use Multi value field as keyword (in keywords........). It is good to have only one dictionary item for one word (like APC) and then define multivalue for keyword, where you can fill "APC", "apc", "apc.org"... It is important for English, but it is crucial for such languages as is Czech with different kinds of words.

Notes:

  • Use this feature mainly for fulltexts of item and not in item-listing, since it is quite time consumming (although it is implemented as quick as possible).
  • Contents of 'HTML' tags are not searched, as the content of the block elements H1-6, script and a is neither.
  • Do not use only a part of the string as a search term, for this directive searches for entire words only.

{log} Logarithmic function evaluation

Syntax:

{log:number:base}

Return the logarithmic value of the number, with the base.

{<fieldID>} - Reading Field Value

Syntax:

{<fieldID>}

where <fieldID> should be 16 chracters long field id which exist in the slice the template is applied to. ActionApps reads the value of that field for a particular item and replaces it (prints it out) as it is in the database.

Example:

{text...........1}

{<variable>} - Reading a Value of a Variable

Syntax:

{<variable>}

where variable must be a name of an existing variable defined in site module (apc_state) or through als[variable] the url parameter.

Example: Say you have defined the alias through the

...view.php3?vid=123&als[heading]=My Page

then use

<h1>{heading}</h1>

If the variable doesn't exist, the result is an empty string.

{const} - Reading Category Values

ActionApps Categories and Constants (the obsolete,simple ones) are stored in a special table (not in slice, unlike preferred Related Items). The relation between the table that holds the content and the table that holds the list of constants is done through the "value" of the constant. If you need to lookup another column from this table and you only know the value, you use this function.

Syntax:

{const_<column_name>:<fieldID>}

Where <column name> one of the valid column names listed below, and <fieldID> is a valid Term#Field_IDs which should have a category group associated to it through the Field properties, in other words should be one of the input types that allow user to select from a list of options.

Example:

{const_name:category.......1}

displays name of constant stored in field category.......1

The list of valid values for <column_name>:

const_short_id short_id
const_name name
const_value value (the same as {category.......1} )
const_pri priority number
const_group name of constant group
const_class class (APC parent category)
const_id long constant id
const_description description (defined on hierarchy editor pages)

{view} - Including Views

You can include the output of any ActionApps view into any design template. Most of the time you will be using this to include your views in the site module. But you can also can include a view within another view, include the output of a certain view as a parameter for any function etc. Put simply, use anywhere in ActionApps where {} syntax is valid. This a powerful function (with a really bad name).

Syntax:

{view.php3?vid=<View ID>[&parameter1&parameter2&...]}

Where <View ID> must be a valid view ID. You can pass URL parameters to the view as if you were calling it via URL, but they can also be expressions enclosed in {}, which will evaluate first.

Example 1:

{view.php3?vid=123}

Returns content of view 123.

Example 2:

{view.php3?vid=122&cmd[122]=c-1-{f}}  

f is a variable, a value of which will be passed to the 1st condition of the view 122

Example 3:

{view.php3?vid=33&cmd[33]=x-33-{relation.......1}} 

use this for displaying related items

{alias} - Using alias functions

Modify the value through an alias function. Syntax:

{alias:<the field>:<alias function>:<parameters>}

So, in text (format string) could be the publish date displayed by {alias:publish_date....:f_d:j.n.Y}. There you can use any alias function with any parameters.

The parameters could be nested, so inside curly braces you can use any alias, any other field ({headline........}) or any other in-line alias definition. There is no limit in level of nesting.

Example:

conditional display of date could look:

{alias:switch.........1:f_c:text:{alias:publish_date....:f_d:j.n.Y}<!--:-->::}

or if we have 06/19/2002 alias defined:

{alias:switch.........1:f_c:text:06/19/2002<!--:-->::}

Both this constructs displays date only if switch.........1 is equal to 'text'. ...

{img} URL modify

Modifies a long image URL to short one for phpThumb script.

Syntax:

{img:<url>:<phpthumb_params>}

Example - Creates link to modified image using phpThumb - like:

<img src="{img:{img_url.........}:w=150&h=150}">

see http://phpthumb.sourceforge.net/demo/ for phpThumb parameters

{switch} - Comparing Values

Switch extends the functionality conditional expressions, otherwise managed f_c function. Switch provides more flexibility through giving more options, regular expressions, etc. Switch takes it's logic from the php switch statement, although the syntax is different.

Syntax:

{switch(<expression>)<value1>:<output1>:....:<valueN>:<outputN>[:<default_output>]} 

where

  • <expression> is any valid AA expression (you can/will use {} in there)
  • <value1> - <valueN> is the regular expression value which the result of the <expression> will be compared with
  • <output1> - <outputN> is the result of the {switch} expression if the <value1> matches the result of <expression>
  • <default_output> is the result if no match is found among <value1> - <valueN>

Note: Because ':' is used as a separator, if you need to use ':' in either <value> or <output> you must prefix it with a '#' escape character, i.e. "#:"

Example:

{switch({number.........1})1:one:2:two:[3-7]:more:too much}

ActionApps evaluates the <expression>, which is the value of the >number.........1 field in our case. If content of the field is equal to 1, the 'one' is the result and will be printed. Because <values> are regular expressions, we can specify the third option as [3-7] which means any number in range between 2 and 7. The default option is 'too much' in our case. The evaluation process goes through values from left to right, the the first match is taken and no further evaluation is performed.


Another example displays text 'Continuos grant', if the field unspecified....2 is filled by 'yes', 'on', 'true' or '1'. Else it displays expiry date:

{switch({unspecified....2})yes|on|true|1:Continuous grant::12/11/2007}

Display of phone number, if specified (note that '#:' is an escaped ':' to distinquish from the argument separators):

{switch({con_phone......1}).+:Tel#:{con_phone......1}}

.+ (or just . (dot)) means non empty string in regular expressions. If you are not familiar with "regular expressions", please look at any tutorial. Regular expressions are very powerfull and you will find it usefull not only in ActionApps.

Remember, that regular expressions searches for substring, so if you want to compare exact value, there are two possibilities:

{switch({number..........})^14$:exactly fourteen}

^ is begin of the line in regular expressions, $ is end of line

{switch(x{number..........}x)x14x:exactly fourteen}

Used a trick with added two random characters in the expression (since expression could be any AA string)

Last example the flexibility of the <expression>. IT can be any valid ActionApps expression, and the of nesting of curly bracket expressions is unlimited.

{switch({disc_count......})[1-9][0-9]*:There is discussion under this item}

{preg_match}- Pattern Matching

--Marek 21 October 2005 20:31 (CEST)
{preg_match} is not in the stable release yet as of today.

Useful for extracting parts of the string that match a certain pattern.

Syntax:

{preg_match:/<pattern>/:<subject>}

where <pattern> is a perl regular expression as described in php preg_match pattern function manual, and <subject> can be any valid ActionApps expression.

Example:

{preg_match:/[0-9]*/:some text with number 25452 in it}

which returns 25452 (based on specified regular expression)

{math} - Mathematical Functions

This function allows you to perform some computatation on the values stored in the slice.

Syntax:

{math(<result_formatting>)<description1>:<expression1>:...:<descriptionN>:<expressionN>}

where:

<result_formatting> has 3 parameters separated by '#' (number of decimals # decimals separator # thousands separator)
<description> can be any text or html and is displayed before result of expression ("#:" mean ":")
<expression1> in expression you can use numbers (decimal separator is ".". Aliases can be used of course) and characters: + - / * ^ . ( )

Example 1 - calculate points in a quiz

<img src="red.gif"   height=10 width="
{math(0#,#) : {_#ANSVER1_} / ({_#ANSVER1_} + {_#ANSVER2_} + {_#ANSVER3_})* 100}%">  _#ANSVER1_ <br>
<img src="blue.gif"  height=10 width="
{math(0#,#) : {_#ANSVER2_} / ({_#ANSVER1_} + {_#ANSVER2_} + {_#ANSVER3_})* 100}%">  _#ANSVER2_ <br>
<img src="green.gif" height=10 width="
{math(0#,#) : {_#ANSVER3_} / ({_#ANSVER1_} + {_#ANSVER2_} + {_#ANSVER3_})* 100}%">  _#ANSVER3_ <br>

if _#ANSVER1 = 25, _#ANSVER2 = 50, _#ANSVER3 = 250 result will be (respectively):

<img src="red.gif" height=10 width="8%">  25   <br>
<img src="blue.gif" height=10 width="15%">  50   <br>
<img src="green.gif" height=10 width="77%">  250   <br>

Example 2 - cost of ordered services last year

{math(2#,# ) <br>mails=:{_#NOOFEMAI}*{_#EMAPRICE}:
             <br>web=:{_#WWWPRICE}:
             <br>technical support=:{_#NOOFHOUR}*{_#HOURPRIC}:
<br><hr>total={_#NOOFEMAI}*{_#EMAPRICE}+{_#WWWPRICE}+{_#NOOFHOUR}*{_#HOURPRIC}
}

result:

mails=450,00
web=1500,00
technical support=2400,00
----------------------------
total=4350,00

{include} - Including External Page

You can use this directive for an inclusion of a remote file or an output of some script

Syntax:

{include(<url>)}

which will be replaced by the output of the HTTP request for the <url> (by the page the URL points at). It a bit like the ssi include directive, or in fact more like a php include statement.

Example 1:

{include(http://www.google.com/)}

Include Google search form in your page.

Example 2:

{include(cgi/counter.pl?id=222)}

as you see here, you can use relative links, although the usefullness of this is questionable since you may not know which page the output of the template will appear at.

Example 3: If you want to include other slices, it could be usefull to pass the URL parameters to the included file. In this case use the special URL_PARAMETERS constant:

{include(fulltext.shtml?URL_PARAMETERS)}</code>

Limitations:

  • It runs only on http:// sites (https:// is not supported before PHP v4.3.0)
  • There is also limited size of included file. The default limit is 400kB, but you can change it by INCLUDE_FILE_MAX_SIZE constant in config.php3.
  • Also you should know, that each include generates one more HTTP request to server, so it may cause performance problems.
--Marek January 9, 2006 19:46 (CET)
Apparently there is more to include:

{include(file)}

{include:file} or {include:file:http}

{include:file:fileman|site}

{include:file:readfile[:str_replace:<search>[;<search1>;..]:<replace>[:<replace1>;..]:<trim-to-tag>:<trim-from-tag>[:filter_func]]}

{user} - Reading Logged In User Values

In AA v2.6 is new Reader Management, where you can control access to directory or file through AA admin interface (see Reader Management). You can then display informations about logged in user by {user:} construct.

The syntax:

{user:<keyword or field ID>}

where <keyword or field ID> are explained on examples below:

{user:} displays login of current user
(this option do not search in database, so it is quick)
You can use this parameter even if you do not use Reader Management slice and you are using standard Apache's password file auth ...
{user:password} displays password of current user (in plain text)
(this option also do not looks into database, but into internal server variable, so it is also quick)
{user:headline........}

displays headline........ field for current user, which is grabbed from Reader Management slice. There is no need to specify in which Reader Management slice user is, because all users are unique in all Reader Management slices.
If the Reader Management slice is protected by password (see 'Slice Admin' -> 'Slice' -> 'Password for Reading'), you have to add slice_pwd parameter to view.php3 (or slice.php3), in which you want to display user's database info.
You can of course display any field from Reader Management slice.

{user:role} displays user's permission role (author/editor/administrator/super/undefined)
(usefull in AA admin interface when you want to display another informations to authors and editors - use it in switch() - like {switch({user:role})editor:_#POSTED_BY} )

Such construct you can use in any view or slice - just like any other aliases.

{scroller} - Adding Pagination

If you want to use page scroller (Page 1 | 2 | 3 | ... ) in view which is a part of the site build on Site Module, you can use this construct. You simply add {scroller} to the bottom of the view which you are calling from the site module - most likely the 'Bottom HTML' field. Example : {scroller:Page ::class="blue"}

Syntax :

{scroller:<begin>:<end>:<add>:<nopage>}

where:

<begin> text to be shown before page numbers
<end> text to be shown after page numbers
<add>

string to be added inside the page link, e.g. class=
<a href=".." class="blue10v">1</a>

<nopage> text to be shown wnen there are (yet) no pages (so the scroller is not displayed)

Then you use the view include, and also utilize the {p} state variable which stores the page number in the site module's spot:

{view.php3?vid=32&set[]=page-{p},listlen-10}


--Marek February 10, 2006 02:43 (CET)
This needs more documenatation, since I ended up grabbing the {p} like this in my site_xxx.php
if ($scr_725_Go) { // there is probabaly a better way of doing this 
	$p=$scr_725_Go;
}
Is there a better way ?
--Noro March 9, 2006 21:01 (CET)
Try this (from example site script):
if (isset($scrl)) {
   $pagevar = "scr_".$scrl."_Go";
   $apc_state['page'] = $$pagevar;
}

{formbreak} - Label tabs of a multipage input form

~ToDo: Describe {formbreak} usage 

Syntax:

{formbreak:<current_tab_name>:<next_tab_name>:. . .}

Allows to specify the name for all tabs, when using inputform formbreaks. The names are separated by ":" and are applied to current and then other tabs. It is useful mainly for the last tab.

{@} - Loop through multiple values

Loop through multivalues in the field.

Syntax:

{@field_id[(alias1[,alias2[...]])]:delimiter:expression}

Example:

{@category.......1}

Lists all values in the field category.......1 separated by ", " - like:

Jane, George, Lucy

{@relation.......2:-}

Lists all values in relation field separated by "-":

8a736554e4a325628a6e459349b9b65b-54e4a3256288a7365a6e459b65b93432-288a7365a6e459b65b9343254e4a3256

Useful in expressions using {item} - like:

{item:{@relation.......2:-}:_#HEADLINE:, }

Displays headlines of all related item specified in relation.......2 field

{@category.......1:,:<em>_#1</em>}

All values will be printed inside <em> tag:

<em>Jane</em>,<em>George</em>,<em>Lucy</em>

Note one limitation here - you can't use curly brackets expressions in "expression" parameter - just text, html and aliases. This limitation you can cleer by using alias as shown in the example below.

{@relation........(_#GET_HEAD): ,:_#1}

Another possibility is to use alias to display each value. _#GET_HEAD is alias defined somewhere in current slice using for example f_t, defined as {item:{loop............}:headline}

The result is, that it displays all the related headlines delimeted by comma (since special field {loop............} contain one value from relation........ field.

{@relation.......1(_#URL_REL_,_#NAME_REL)):, :<a href="_#1">_#2</a>}
{@category.......1(const_name,const_value,_#MY_ALIAS):,:_#1 _#2 _#3}

As you can see, you can use more than one alias for each value. Then you refer to the result as _#1 _#2, ... If you are using constants in the category.......1 field, then you can also get another informations from constant definition, like:

const_name, const_value, const_pri, const_group, const_class, const_counter, const_id, const_description, const_short_id, const_level (the same as with {const})

{go} get url based on current state (apc) and query-string paramater (for Site module)

 {go:<query-string>}

Usage:

 {go:xseo1=faq&xseo2=questions}

Returns "/en/faq/questions" (based on your router (AA_Router_Seo)) (we used {go2url} custom function in previous versions of AA. This function is however core function)

{xid} - Id of the current item on specified level of page tree (in Site module AA_Router_SEO)

 {xid[:<level>]}

Complement to {xseo1},.. variables of AA_Router_Seo

 {xid}

Returns id of current item (the id of {xseo} item)

 {xid:1}

Returns id of item on first level (the id of {xseo1} item) for /cz/project/about-us returns id of "project" item

 {xid:path} 

Returns ids path of current item - like 2587(2877(3004)) as used in {item...} syntax. Good for breadcrumbs:

 {item:{xid:path}: _#HEADLINE:: _#HEADLINK >}

{debug} - Debug or Troubleshoot

Syntax:

{debug}

Because it is sometimes unclear which substitutions are available at a certain point, {debug} will output some hopefully useful information

{#} - Comment

Syntax:

{#<comment>}

as addition to in-line aliases you can {# make comments} which are not displayed in the resulting html code {the result of this expression is always an empty string). It could be nested again, so you can {# comment out _#ALIASES_ as well as fields {headline........} or alias definitions } - nothing of it will appear in the result.

{qs} - get GET parameter from URL

 {qs:<varname>}

Usage:

 {qs:surname}

Returns Havel for http://example.org/cz/page?surname=Havel

{randomstring} - random string

 {randomstring:<length>} 

Usage:

 {randomstring:6}

Returns random string of given length.

Personal tools