Advanced content holder scenarios

Updated on 20-October-2016 at 10:16 AM

Business Catalyst End of life announcement - find out more details.

Dynamic content holders

The ability to display a content holder based on its name can be used in scenarios where you have multiple content holders and you want to choose which one to display based on another condition.

Displaying content holders based on the device type

In this scenario, you create 3 different content holders with different contents and structures named as shown below:

  • Accepted_payments_desktop
  • Accepted_payments_tablet
  • Accepted_payments_phone

In conjunction with the {system_visitorDeviceClass} module you can display the correct content holder depending on the device the site visitor is using.

On the template where you want the accepted payment methods to be shown modify the content holder name like so:

Because the system will dynamically replace the {system_visitorDeviceClass} module with either "desktop", "tablet" or "phone" (see the module's description page for details) the visitor will basically get different content holders.

Displaying content holders based on the URL

Another application is to use named content holders in conjunction with the {module_url } module. The approach is similar to the one above but can be used for a broader variety of applications.

This time create the content holders named like this:

  • Accepted_payments_yellow
  • Accepted_payments_green
  • Accepted_payments_blue

In the template or page insert the content holder like this:

Now all you need to do is add the CH_name parameter to the URL of the page. The system will replace the output of {module_url,CH_name } with the value of the CH_name parameter.

For example if the URL is http://mysite.com/page1?CH_name=blue the content holder with the name "Accepted_payments_blue" will be shown.

If the URL is http://mysite.com/page1?CH_name=something_that_does_not_exist the content holder will not render at all.

This method is very flexible considering you can pretty much put anything in the URL, the name of your customer (assuming they logged into a secure zone first), the 2 letter visitor's country code and so on.