Overview of Awesome Shortcodes and Awesome UI

Awesome UI 2 gives awesome shortcodes platform that forms the base of our Awesome Studio framework for WordPress. By using these commands err… shortcodes you can create almost any kind of WordPress based website or application.

Below you will find a quick overview of which shortcode (aka command) to use when.

Key Points:

WordPress does not allow a Shortcode as attribute. So we use {{}}

To debug, put  aw2_debug around the block you want to debug.

WordPress does not allow the same shortcode within a shortcode, also sometime WordPress does not understand when a shortcode is closed and the same shortcode has started. So use

How a Shortcode is processed

Step 1: All the attributes are parsed for {{}} . They are replaced with their do_shortcode value, if there is a value without an attribute name it is put as main

Step 2: Conditions are checked to see whether this shortcode should be executed. See aw2_if for the conditions. If failed then the shortcode is not executed.
Step 3: The Main Activity is done
Step 4: If a value is to be returned then it is passed through various filters
words
separator
format_date
Step 5: If a value is returned and there is a set_param then the value is saved in the parameter with global scope, if set_local is used then value is saved as variable with local scope, else the value is returned.
Put all your shortcodes in the aw2_module/aw2_page CPT.
Call the page using

To Get and Set arbitrary variables use. The Variable is passed through do_shortcode before saving

To Create a content block which can be accessed repeatedly within the block use
aw2_set_template
aw2_use_template
Helpful when a block has to be executed for both Ajax and Non Ajax
To Get and Set Request, Session and Cookie use
aw2_request
aw2_set_session
aw2_set_cookie
aw2_session
aw2_cookie

Querying the database

If you want to Query the database for multiple records use the following shortcodes
aw2_query_posts
aw2_query_terms
aw2_query_users

All queries return back a collection which has a default id of ‘default_collection’
You can access the collection using aw2_collection to get back count and implode the collection.

To Loop through a Query which returns Multiple Results use

aw2_loop

Within the Loop the current Loop item can be accessed using

aw2_loop_item

You can query the item to find out the index, whether it is odd, even and so on, within the Value to get the value from an associative array or from an object use aw2_loop_value.
aw2_loop_value is exactly same as aw2_value the only difference being that aw2_loop_value access the current loop item.
Since WordPress does not allow same shortcodes within the shortcode, if you want a loop within a loop set a template of the inner loop and then call the template
If you want to Query the database for one record use the following shortcodes
aw2_query_post
aw2_query_term
aw2_query_user

To get value from a query which returns just one object use aw2_value

If you want to execute blocks conditionally, look at Working with Conditions for using If – else conditions.
If – Else also supports basic and , or
aw2_if
aw2_else
aw2_and
aw2_or
For scenarios where you need to have multiple conditions and different executions use Switch Case
aw2_case_else
aw2_switch
aw2_case
If you want to run part of a module then use
aw2_if_part
This will allow you to break your whole block into parts and then call a particular part.
You can run a section based who is logged on aw2_if_logged_in

Updation and Deletion of Database

aw2_insert_post
aw2_set_meta
aw2_set_taxonomy
aw2_delete_post
aw2_delete_term

To run an arbitrary php function use aw2_call_func.

To run any shortcode (beyond aw2) where you want to carry some dynamic attributes use aw2_run_shortcode, remember WordPress does not allow a shortcode as an attribute.

 

Interacting with Client Side

To write JavaScript use
aw2_script
To send a script which will run when doc is ready use
aw2_ready_script
To send style use
aw2_style
When you are using Ajax to transfer data then you can divide the module into three parts using aw2_if_ajax
a) the common block
b)

c)

Use aw2_spa for registering and using JavaScript libraries that are not supported, our SPA library is the most power full way of making JS libraries reusable.

For temporary commenting of blocks and writing help use aw2_ignore it just ignores the blocks within it.

One thought on “Overview of Awesome Shortcodes and Awesome UI”

Comments are closed.