Using shortcodes

Notice : For a more comprehensive and organised Guide, get the YumpeeCMS System Administrator Guide PDF for $19.95
Web Administrator December 3, 2018 1134 views

What are shortcodes

These are codes within YumpeeCMS that can be used to attain more flexible results within your web pages with minimal efforts. Shortcodes can be used to define placeholders within your web page so that once an original source of data is updated, all the places where the shortcodes have been placed will reflect the central change.

 

Ways to use shortcodes

Shortcodes within YumpeeCMS can either be used as an HTML tag or a Yumpee tag. A Yumpee tag is a special kind of tag that triggers a backend scripting of Twig programs. While Twig implementation is beyond the scope of this guide, some examples will be considered in later section to show how this can be achieved.

 

HTML shortcodes

HTML shortcodes are used to load data after the page has already loaded. This is used to avoid lag of web page loads so the web page visitor doesn't have to wait for all data to be fetched before loading.

Adding a widget to a page shortcode

To add a widget to a page use the following format

 

 

 

In the above format

  • widget name refers to the widget to be included on the page as discussed in Chapter 6. This is a compulsory part of this shortcode

  • identifier is the variable name that uniquely identifies the widget. This is optional depending on the widget.

  • options means additional information that the widget requires to render correctly. This will depend on the type of widget.

 

Twig shortcodes

Twig shortcodes are Yumpee tags that are processed before a page is rendered. They are shortcodes that are executed within the rendering stage of a request life cycle. Twig scripting in YumpeeCMS is beyond the scope of this book but to include a Twig shortcode into your web page you will include as below

 

{yumpee_include}[widget_name]{/yumpee_include}

 

When the above is executed, the Twig script contained in widget_name will be executed and the results displayed on the page.

 

 

Also within the widget_name there are other shortcodes that can be used to interract with different parts of the YumpeeCMS framework. For example

 

{% set products = {yumpee_data}tbl-products:category=internet:100{/yumpee_data} %}

 

In the above Yumpee Twig code snippet {yumpee_data} is a Twig shortcode requesting for data from the tbl-product form data to be fetched. It requests a filter of products where the category is internet and requests for 100 products. (To learn more about Twig Programming in YumpeeCMS get the Application Developer's Guide – more info on the website http://www.yumpeecms.com)

 

Email Shortcodes

These are shortcodes that are included as part of an email hook when a form is submitted to the YumpeeCMS.

 

Settings Shortcodes

These are shortcodes that are used within the System->Settings page of YumpeeCMS.

 

 

One way that Settings shortcode can be used is by including the Yumpee Tag

{yumpee_setting}[setting name]{/yumpee_setting}

For example typing {yumpee_setting}custom_mmh_address{/yumpee_setting} will insert the address 3, Park Road, Nambour into any part of your website.

 

Another way that Setting shortcodes is to create dynamic contents that are from the processing of a Twig script.They can be used to include certain Twig files that will now spit contents into the fields value of the settings.

 

For example if you define a setting called – custom_currency and assign it a value of {yumpee_include}prg-get-currency{/yumpee_include}

 

Whenever the custom_currency field is called, YumpeeCMS will look for the prg-get-currency Twig program and return the result into the currency field. This makes it possible to dynamically change settings without it affecting everyone else using the system.