Difference between revisions of "Alias Functions and Parameters"

From ActionApps Documentation
Jump to: navigation, search
Line 1: Line 1:
<aafaq id=1768> ~ToDo: 1768 What are the Parameters of the Alias Functions</aafaq>
+
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.<br /> 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.<br />
 +
 
 +
 
 +
 
 +
=== f_c Condition ===
 +
''Parameters: ''
 +
&lt;condition&gt;:&lt;begin&gt;:&lt;end&gt;:&lt;else&gt;:&lt;subject&gt;:&lt;skip filed&gt;
 +
 
 +
''Description:''  Tests if the value of the <code>&lt;condition&gt;</code> parameter matches the <code>&lt;subject&gt;</code>, in which case it prints <code>&lt;begin&gt;</code>, then (unless <code>&lt;skip filed&gt;</code> is set to 1) followed by the value of <code>&lt;subject&gt;</code> (or the current field the alias is attached to if the parameter is empty, followed by <code>&lt;end&gt;</code>. If there is no match, the result is the value of <code>&lt;else&gt;</code> parameter.
 +
To negate the comparision, use "!" character at the begin of <code>&lt;condition&gt;</code>
 +
 
 +
 
 +
''Example 1:''
 +
1:Yes&lt;!--:--&gt;:No
 +
 
 +
This example is usable for example for Highlight field - it shows Yes or No depending on the value of the highlight field
 +
 +
''Example 2:''
 +
!:Email#:::
 +
 
 +
If e-mail field is filled, it shows "Email: email@apc.org" (for example), but if it is not filled, it shows nothing
 +
 
 +
 
 +
~ToDo: Convert all the functions below to the same format as [Alias_Functions_and_Parameters#f_c f_c]
 +
 
 +
{| cellpadding="3" align="center"
 +
| class="tabtit" | Function
 +
| class="tabtit" | Parameter
 +
| class="tabtit" | Description
 +
|-
 +
| class="tabfnc" valign="top" | f_x
 +
| colspan="2" | transformation
 +
|-
 +
|
 +
| content value (pairs) pairs
 +
|
 +
the content of the field and the value to return, the content can be a regular expression as in http://www.php.net/manual/en/ref.regex.php
 +
|-
 +
|
 +
| default
 +
| value returned if no match
 +
|-
 +
| class="tabfnc" valign="top" | f_0
 +
| colspan="2" | null function (nothing shown)
 +
|-
 +
|
 +
| none
 +
|
 +
|-
 +
| class="tabfnc" valign="top" | f_h
 +
| colspan="2" | print field content due to html flag set (escape html special characters or just print)
 +
|-
 +
|
 +
| class="tabparam" | delimeter
 +
| if ''delimeter'' parameter is specified, the field with multiple values are displayed as list, delited by ''delimeter''
 +
|-
 +
| class="tabfnc" valign="top" | f_d
 +
| colspan="2" | prints date in user defined format
 +
|-
 +
|
 +
| class="tabparam" | format
 +
|
 +
format string just like in PHP (like "m-d-Y") - see [http://php.net/date PHP manual]
 +
|-
 +
| class="tabfnc" valign="top" | f_i
 +
| colspan="2" | prints image scr (&lt;img src=...) - NO_PICTURE for none (the functionality of this alias function can be created as conditional f_c function as well)
 +
|-
 +
| class="tabfnc" valign="top" |
 +
| none
 +
|
 +
|-
 +
| class="tabfnc" valign="top" | f_n
 +
| colspan="2" | unpacked id
 +
|-
 +
|
 +
| none
 +
|
 +
|-
 +
| class="tabfnc" valign="top" | f_g
 +
| colspan="2" | prints image height atribut (img height=...) or clears it (the functionality of this alias function can be created as conditional f_c function as well)
 +
|-
 +
|
 +
| none
 +
|
 +
|-
 +
| class="tabfnc" valign="top" | f_w
 +
| colspan="2" | prints image width atribut (&lt;img width=...) or clears it
 +
|-
 +
|
 +
| none
 +
|
 +
|-
 +
| class="tabfnc" valign="top" | f_a
 +
| colspan="2" | prints abstract or grabed fulltext text field
 +
|-
 +
|
 +
| class="tabparam" | length
 +
| length - number of characters taken from field_id (like "80:full_text.......")
 +
|-
 +
|
 +
| class="tabparam" | field_id
 +
| id of fulltex field
 +
|-
 +
| class="tabfnc" valign="top" | f_f
 +
| colspan="2" | prints link to fulltext (hedline url)
 +
|-
 +
|
 +
| class="tabparam" | link_only
 +
| field id (like "link_only.......") where switch between external and internal item is stored
 +
|-
 +
|
 +
| class="tabparam" | redirect
 +
| url of another page which shows the content of item (like "link_only.......:http#://www.ecn.cz/articles/solar.shtml") (note the #: in previous example!)<br /> this page should contain SSI include ../slice.php3 of course
 +
|-
 +
| class="tabfnc" valign="top" | f_b
 +
| colspan="2" | prints text with link to fulltext - more general version of f_f function<br />param: link_only:url_field:redirect:txt:condition_fld (hedline url)
 +
|-
 +
|
 +
| class="tabparam" | link_only
 +
| field id (like "link_only.......") where switch between external and internal item is stored
 +
|-
 +
|
 +
| class="tabparam" | url_field
 +
| field id of external url for link_only<br /> (like hl_href.........)
 +
|-
 +
|
 +
| class="tabparam" | redirect
 +
| url of another page which shows the content of item (like "link_only.......:http#://www.ecn.cz/articles/solar.shtml") (note the #: in previous example!)<br /> this page should contain SSI include ../slice.php3 of course
 +
|-
 +
|
 +
| class="tabparam" | txt
 +
| if txt is field_id content is shown as link, else txt
 +
|-
 +
|
 +
| class="tabparam" | condition_fld
 +
| field id - if no content of this field, no link
 +
|-
 +
|
 +
| class="tabparam" | addition
 +
| additional parameter to &lt;a tag (like "target=_blank")
 +
|-
 +
| class="tabfnc" valign="top" | f_t
 +
| colspan="2" | converts text to html or escape html (due to html flag)
 +
|-
 +
|
 +
| none
 +
|
 +
|-
 +
| class="tabfnc" valign="top" | f_s
 +
| colspan="2" | print database field or default value if empty (the functionality of this alias function can be created as conditional f_c function as well)
 +
|-
 +
|
 +
| class="tabparam" | default
 +
| default value (like "javascript: window.alert('No source url specified')")
 +
|-
 +
| class="tabfnc" valign="top" | f_l
 +
| colspan="2" | prints field as link, if field_id in $param is defined, else prints just field
 +
|-
 +
| class="tabfnc" valign="top" |
 +
| class="tabparam" | field_id
 +
| field_id of possible link (like "source_href.....")
 +
|-
 +
| class="tabfnc" valign="top" | f_e
 +
| colspan="2" | http://actionapps.org/aa/admin/itemedit.php3?AA_CP_Session=f48237b26098d261a71de80ded1c49c4&amp;edit=1&amp;encap=false&amp;id=6525acb6a0ceb34e3db375618efe19f0 used on admin page index.php3 for itemedit url
 +
|-
 +
|
 +
| none
 +
|
 +
|-
 +
| class="tabfnc" valign="top" | f_u
 +
| colspan="2" |
 +
calls user defined function (see [http://actionapps.org/faq/detail.shtml?x=1703 How to create new aliases])
 +
|-
 +
|
 +
| class="tabparam" | function
 +
| name of called function in include/usr_aliasfnc.php3 file
 +
|-
 +
|
 +
| class="tabparam" | parameter
 +
| parameters passed to function
 +
|-
 +
| class="tabfnc" valign="top" | f_m
 +
| colspan="2" | mailto link - prints: "begin&lt;a href="(mailto:)$col"&gt;field/text&lt;/a&gt;"<br />if no $col is filled, prints "else_field/text"
 +
|-
 +
|
 +
| class="tabparam" | begin
 +
| text before link (for example "e-mail")
 +
|-
 +
|
 +
| class="tabparam" | field/text
 +
| if field id specified, the field is used as link text else the text is used insteed.
 +
|-
 +
|
 +
| class="tabparam" | else_field/text
 +
| if no e-mail addres specified in $col, the field content (or text) is displayed
 +
|-
 +
|
 +
| class="tabparam" | linktype
 +
| mailto / href (default is mailto) - it is possible to use this function for links, too - just type "href" as last parameter
 +
|-
 +
| class="tabfnc" valign="top" | i_s
 +
| colspan="2" | image size and other properties - as default prints: '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. <br />Returns empty string if it cannot determine the width or height.
 +
|-
 +
|
 +
| class="tabparam" | information
 +
|
 +
* 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', ...)
 +
|-
 +
| class="tabfnc" valign="top" | f_y
 +
| colspan="2" |
 +
Expanded string: expands the string in the parameter. <br />If you need use aliases in a database field. It can be used e.g. for including photographs from the slice "Photogallery" to the field "full_text......." in the slice "Articles". See an [http://actionapps.org/faq/detail.shtml?x=2090 Example].
 +
|-
 +
|
 +
| class="tabparam" | string to expand
 +
| If specified then this string is expanded, if not specified then expands the contents of the field.
 +
|}
 +
 
 
<aafaq id=1674> ~ToDo: 1674 What paramater substitution is done in f_v </aafaq>
 
<aafaq id=1674> ~ToDo: 1674 What paramater substitution is done in f_v </aafaq>

Revision as of 00:18, 24 October 2005

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_c Condition

Parameters:

<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 comparision, use "!" character at the begin of <condition>


Example 1:

1:Yes<!--:-->:No

This example is usable for example for Highlight field - it shows Yes or No depending on the value of the highlight field

Example 2:

!:Email#:::

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


~ToDo: Convert all the functions below to the same format as [Alias_Functions_and_Parameters#f_c f_c]

Function Parameter Description
f_x transformation
content value (pairs) pairs

the content of the field and the value to return, the content can be a regular expression as in http://www.php.net/manual/en/ref.regex.php

default value returned if no match
f_0 null function (nothing shown)
none
f_h print field content due to html flag set (escape html special characters or just print)
delimeter if delimeter parameter is specified, the field with multiple values are displayed as list, delited by delimeter
f_d prints date in user defined format
format

format string just like in PHP (like "m-d-Y") - see PHP manual

f_i prints image scr (<img src=...) - NO_PICTURE for none (the functionality of this alias function can be created as conditional f_c function as well)
none
f_n unpacked id
none
f_g prints image height atribut (img height=...) or clears it (the functionality of this alias function can be created as conditional f_c function as well)
none
f_w prints image width atribut (<img width=...) or clears it
none
f_a prints abstract or grabed fulltext text field
length length - number of characters taken from field_id (like "80:full_text.......")
field_id id of fulltex field
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#://www.ecn.cz/articles/solar.shtml") (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#://www.ecn.cz/articles/solar.shtml") (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)
none
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 http://actionapps.org/aa/admin/itemedit.php3?AA_CP_Session=f48237b26098d261a71de80ded1c49c4&edit=1&encap=false&id=6525acb6a0ceb34e3db375618efe19f0 used on admin page index.php3 for itemedit url
none
f_u

calls user defined function (see How to create new aliases)

function name of called function in include/usr_aliasfnc.php3 file
parameter parameters passed to function
f_m mailto link - prints: "begin<a href="(mailto:)$col">field/text</a>"
if no $col is filled, prints "else_field/text"
begin text before link (for example "e-mail")
field/text if field id specified, the field is used as link text else the text is used insteed.
else_field/text if no e-mail addres specified in $col, 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
i_s image size and other properties - as default prints: '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.
information
  • 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_y

Expanded string: expands the string in the parameter.
If you need use aliases in a database field. It can be used e.g. for including photographs from the slice "Photogallery" to the field "full_text......." in the slice "Articles". See an Example.

string to expand If specified then this string is expanded, if not specified then expands the contents of the field.

What paramater substitution is done in f_v

f_v takes a parameter on which certain substitution is done.

  • _#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 output by f_n.
  • _#id.............. will get the id of the record, (unclear if this is unpacked or packed)
  • _#short_id........ will get the short id of the record
  • _#slice gets the id (unclear if packed or unpacked) of the slice
  • _#headline........ (or any other field) will get that field, or a list of them separated by "-"
  • In addition any of the { ... } syntax can be used, (See How to Use Aliases)