Alias Functions and Parameters

From ActionApps Documentation
Jump to: navigation, search
~ToDo: Rewrite this paragraph

When we setting up aliases for database field on se_fields.php3 page, we sometimes need to change the behavior of alias in som way or we need to pass some parameter for alias handling function such as f_f. The Parameters field is the right place, how to do it. The list of parameters for each alias function follows.
In some cases we need to pass more than one parameter to alias function. In such case the aliases are separated by colon character. If we need to use colon inside parameter, we just use #: string instead of : character.

f_a - Abstract



Description: Prints abstract if it's there, and if the abstract is missing, it will grab a specified part of the fulltext field and return that as an abstract. This function has following 3 parameters:

  • <length> is an integer number which specifies the maximum nubers of characters which will be grabbed from the other field.
  • <fulltext> should be a field id of a field that contains fulltext (mostly full_text.......) where the text will be extracted from. If this parameter is left empty, the text is grabbed from the associated field itself.
  • <paragraph> - boolean 1 or 0. When set to 1, it attempts to do some inteligent grabbing - it searches for the first paragraph (text until <BR> or <P> or </P> or at least '.' (dot)). If it doesn't find any of those it returns first <length> characters.

f_c - Condition


<condition>:<begin>:<end>:<else>:<subject>:<skip filed>

Description: Tests if the value of the <condition> parameter matches the <subject>, in which case it prints <begin>, then (unless <skip filed> is set to 1) followed by the value of <subject> (or the current field the alias is attached to if the parameter is empty, followed by <end>. If there is no match, the result is the value of <else> parameter. To negate the comparison, use "!" character at the begin of <condition>.

Example 1:


This example is usable for example for Highlight field - it shows Yes or No depending on the value of the highlight field, while the actual value (1) is wrapped in HTML comment tag.

Example 2:


If e-mail field is filled, it shows "Email:" (for example), but if it is not filled, it shows nothing

f_x - Transformation

Transformation. Parameters:


Description: The value of the associated field (or any input value if you use f_x through the {alias...} construct will be compared with each <patternX> in sequence, once the match is found the corresponding <resultX> is returned. If no match is found, <default> is returned <patternX> can be a php regular expression, as described in php manual

Note that this function is similar to {switch}, which is now more widely used.

f_0 - Null

Description: This function returns an empty string. Newly created fields default to this function (2nd and 3rd alias).The function has no parameters.

f_h - Print HTML



Description: Print HTML prints the text in the field depending on whether it's marked on HTML or plain text (that is determined by reading the value of the html flag ). HTML will simply print it as it is, in case of a plain text any HTML tags will be stripped and line breaks and paragraphs added. If the field contains multiple values, all values will be printed separated by the <delimiter> sign.

f_d - Date Formatting


<format string>

Description: Because ActionApps stores date and time as a Unix timestamp (number of seconds since the beginning of Unix epoch), you have to use this function frequently to display dates in a human readable format. The desired format can be expressed in the <format string>, which has the same syntax as Date Function php .


F j, Y, g:i a                 March 10, 2001, 5:16 pm
m.d.y                         03.10.01
j, n, Y                       10, 3, 2001
Ymd                           20010310
D M j G:i:s T Y               Sat Mar 10 15:16:08 MST 2001
H:i:s                         17:16:17

More at Date Function manual.

i_s - Calculate img properties




Attempts to calculates image size and other properties, provided that the value of the fields is a valid URL (img source) pointing to an existing image. By default it will return: 'height="xxx" width="yyy"', where xxx and yyy are the height and width of the image in pixels. Other properties can be printed as well. Returns empty string if it cannot determine the width or height. The  <information> can be one of the following values: 
  • html (default) - returns image size as HTML atributes (height='xxx' width='yyy')
  • width - returns width of image in pixels
  • height - returns width of image in pixels
  • imgtype - returns flag indicating the type of the image: 1 = GIF, 2 = JPG, 3 = PNG, 4 = SWF, 5 = PSD, 6 = BMP, 7 = TIFF(intel byte order), 8 = TIFF(motorola byte order), 9 = JPC, 10 = JP2, 11 = JPX, 12 = JB2, 13 = SWC, 14 = IFF, 15 = WBMP, 16 = XBM
  • mime - returns mimetype of the image (like 'image/gif', 'application/x-shockwave-flash', ...)

f_i - Print img tag

Description: This function is deprecated. It prints the content of the field wrapped in the (<img src=...>) tag, so the content of the field should be an absolute or relative URL. If the field is empty, it prints "NO_PICTURE". The function is deprecated because the same behaviour can be achieved through the f_c function with parameters :::NO_PICTURE. The function has no parameters.

f_g - Print img heigth

Description: This function is deprecated. It's purpose is to add height parameter to the <img> if it's known (= filled in by the user). It prints height="<field value>" if <field value> is not empty, otherwise the result is an empty string. You can use f_c function to achieve the same behaviour. The function has no parameters.

f_w - Print img width

Description: This function is deprecated. It's purpose is to add width parameter to the <img> if it's known (= filled in by the user). It prints width="<field value>" if <field value> is not empty, otherwise the result is an empty string. You can use f_c function to achieve the same behaviour.

f_n - Unpacked IDs

Description: Prints unpacked id, so you can use it to get a binary representation of 'item id' or 'slice id' that ActionApps uses internaly. See Item ID. The function has no parameters.

f_m - E-mail


<begin>:<field/text>:<else_field/text>:<linktype>:<tag addition>:<hide email>

Description: This function is commonly used to display email address. It prints:

<begin><a href="(mailto:)<field value><"><field/text></a>"

if the <field value> (which is the value of the associated field or a value send through {alias} ) is empty, it prints the <else_field/text>. The function can also add adittional tags to the resulting <a> tag and hide emails from email harvesters (through the use of javascript).

  • <begin> - text before link (for example "e-mail")
  • <field/text> - if field id is specified, the field is used as link text, otherwise the text is used insteed.
  • <else_field/text> - if no e-mail addres specified in, the field content (or text) is displayed
  • <linktype> - mailto / href (default is mailto) - it is possible to use this function for links, too - just type "href" as last parameter
  • <tag addition> - adds parameters to the resulting <a> tag
  • <hide email> - 0 or 1 boolean value, if 1 use javascript to hide email address from harvesters

f_y - Expand {} tags in user input


<text/field id>

Description: This function forces the interpretation of {} syntax inside the specified <text/field id&gt or an associated field if the parameter is empty. This way you can for instance include other views inside the fulltext wherever the user puts properly formatted {view} construct.

f_v - View


<view parameters>

Description: This function, which is commonly used to display related items calls the specified view. In addition, it defines certain aliases which can be of use for generating corect view parameters. You can use those aliases in the <view parameters>, and following substitutions will be performed:

  • _#this - is replaced by the content of the field we are working on, typically this is the long id of the item being referenced. If there are multiple id's they are strung together seperated by "-" which is what view.php3 expects in its parameters.
  • _#slice - is replaced by the slice id.
  • _#unpacked_id - is replaced by the id of the record as returned by f_n.
  • _#id.............. - will get the unpacked long id of the record
  • _#short_id........ - will get the short id of the record
  • _#slice - gets the unpacked id of the slice
  • _#headline........ - (or any other field) will get that field, or a list of them separated by "-"



If the associated field contains multiple item IDs of related items, the _#this will be replaced by a list of all of them separated by "-", so it can be something like:


Assuming that view 110 prints links to the related items, as a result of this function you get a list of related items formatted according to the template defined in view no.110.

f_u - User defined function


<function name>:<parameter1>:...:<parameterN>

Description: This function can be used to invoke any user defined function. <function name> must be the name of a function defined in include/usr_aliasfnc.php3 file. Any number of parameters can be passed to the function through the second and consequent parameters. If the function is not defined, you'll get a php error. For information on how to write your own function see Creating custom alias function.

~ToDo: Convert all the remaining functions below:
Function Parameter Description
f_f prints link to fulltext (hedline url)
link_only field id (like "link_only.......") where switch between external and internal item is stored
redirect url of another page which shows the content of item (like "link_only.......:http#://") (note the #: in previous example!)
this page should contain SSI include ../slice.php3 of course
f_b prints text with link to fulltext - more general version of f_f function
param: link_only:url_field:redirect:txt:condition_fld (hedline url)
link_only field id (like "link_only.......") where switch between external and internal item is stored
url_field field id of external url for link_only
(like hl_href.........)
redirect url of another page which shows the content of item (like "link_only.......:http#://") (note the #: in previous example!)
this page should contain SSI include ../slice.php3 of course
txt if txt is field_id content is shown as link, else txt
condition_fld field id - if no content of this field, no link
addition additional parameter to <a tag (like "target=_blank")
f_t converts text to html or escape html (due to html flag)
f_s print database field or default value if empty (the functionality of this alias function can be created as conditional f_c function as well)
default default value (like "javascript: window.alert('No source url specified')")
f_l prints field as link, if field_id in $param is defined, else prints just field
field_id field_id of possible link (like "source_href.....")
f_e used on admin page index.php3 for itemedit url