Documentation / Tutorials / Tutorials & How to’s

All Supported Condition

/ Tutorials & How to’s / All Supported Condition

Awesome Studio supports following list of conditions, which can be applied to any awesome studio supported shortcodes. If any of these conditions result in false then shortcode will not get executed.

This is a shorthand list, and they can also be used with aw2.if shortcode.

Condition Description Example
ignore This will ignore the shortcode, ie shortcode will not get executed.  [aw2.get app.path ignore=true /]
empty empty condition checks for string if='' or null or does not exist. For array, it will be true if it is empty or does not exist. [aw2.get app.path empty="{request.path}" /] or

[aw2.get app.path empty="{app.option}" /]

not_empty not_empty condition for string checks if it exists and is not equal to ''. For array it returns true if has at least 1 element. [aw2.get app.path not_empty="{request.path}" /] or

[aw2.get app.path not_empty="{app.option}" /]

request_exists It checks if the element exists in $_REQUEST  [aw2.get request.first_name request_exists="first_name" /]
request_not_exists If the element does not exists in $_REQUEST  [aw2.set first_name='awesome' request_not_exists="first_name" /]
request_part True if there is a query string called part with the specified value.
True if there is no query string called part and the value is 'default'.
[aw2.if request_part="default"]

It will show if their is no part in request parameter

[/aw2.if]

[aw2.if request_part="show_msg"]

It will show this when part is setup as show_msg

[/aw2.if]

device 'mobile,tablet,desktop'
Only if the Device Matches. Comma separated for multiple
[aw2.do device='mobile']

show me if the request is coming from mobile device

[/aw2.do]

 

[aw2.do device='mobile,tablet']

show me if the request is coming from mobile or a tablet device

[/aw2.do]

 

ajax executes if ajax request [aw2.if ajax=true]

execute this only if this module is executed via an ajax request

[/aw2.if]

not_ajax excutes if not_ajax [aw2.if not_ajax=true]

do not execute this if this module is executed via an ajax request, only execute if this is non ajax request

[/aw2.if]

cond= equal='' If the element exists.

Within this example the content in meta will be compare with demo_word.

[aw2.if cond="{{aw2.get item.meta.demo_text}}" equal="demo_word"] [/aw2.if]

or

[aw2.if cond="{{aw2.get item.meta.demo_text}}" equal="{{aw2.get item.meta.text}}"] [/aw2.if]

cond= not_equal='' If the element exists [aw2.if cond="{{aw2.get item.meta.demo_text}}" not_equal="test"] [/aw2.if]
cond= less_equal='' If cond <leq [aw2.if cond="{{aw2.get module.qu.demo_posts}}" less_equal="12"]
[/aw2.if]
cond= less_than='' If cond <leq [aw2.if cond="{{aw2.get module.qu.demo_posts}}" less_than="12"]
[/aw2.if]
cond= greater_than='' If cond <leq [aw2.if cond="{{aw2.get module.qu.demo_posts}}" greater_than="12"]
[/aw2.if]
cond= greater_equal='' If cond <leq [aw2.if cond="{{aw2.get module.qu.demo_posts}}" greater_equal="12"]
[/aw2.if]
odd True if Integer is odd else false [aw2.if loop.odd ][/aw2.if]

or

[aw2.true loop.odd ][/aw2.true]

even True if Integer is odd else false [aw2.if loop.even ][/aw2.if]

or

[aw2.true loop.even ][/aw2.true]

true=<integer,boolean,array> For integer if =1
For boolean if=true
For array true if has at least 1 element
For string if not '' and not null
[aw2.true loop.even ]

[/aw2.true]

false=<integer,boolean,array> For integer if = 0
For boolean if=false
For array true if empty or does not exist
For string if null or ''
[aw2.false loop.even ]

[/aw2.false]

user_can= if the user has the right example
user_cannot= if the user does not have the right example
logged_in=true true if somebody is logged in else it is false [aw2.if not_logged_in=true]
User is not logged in
[/aw2.if]
not_logged_in=true true if nobody is logged in else false [aw2.if logged_in=true]
do something user is logged in
[/aw2.if]
role= true if somebody is logged and role is role id example
not_role= true if nobody is logged in or role is not role id example
list= contains= If the term exists in the list

If we have comma separated list we can match every element in list.

[aw2.set module.cities="Pune, Mumbai,..., all-india" /]

[aw2.if list="{{aw2.get module.cities}}" contains="all-india"]
[/aw2.if]

list= not_contains= If the term does not exist in the list

Condition will true if Goa is not in list of cities.

[aw2.set module.cities="Pune, Mumbai, all-india" /]

[aw2.if list="{{aw2.get module.cities}}" not_contains="Goa"]
[/aw2.if]

in_array= contains= in_array is used to test if a value exists within an array. you have to pass the name of the key set in stack. [aw2.if in_array="module.applicable_for" contains="web" ]

I am inside web

[/aw2.if]

"applicable_for" is set in the stack

in_array= not_contains= If the term does not exist in the list [aw2.if in_array="module.applicable_for" not_contains="web" ]

their is no web

[/aw2.if]

"applicable_for" is set in the stack

require_once= when require_once is used, within a session  it will be executed only once with the specified id, generally used on module styles. [aw2.client style require_once='{module.slug}']

.class{

}

[/aw2.client]

Categories
Most Popular