If you have worked in Joomla for any time, you've probably used the excellent extensions by Peter at Regular Labs. Recently, he unveiled a very useful new extension called Conditional Content.
Previously, it was difficult to get full control over the "4 Ws" of how your content displayed ... who, what, where, and when. This required multiple Joomla extensions and often a bit of PHP coding. Conditional Content makes it much easier to show your content only under certain conditions.
How Conditional Content works
You can install Conditional Content for free, either using the "Install from Web" feature in Joomla, or by downloading from the Regular Labs website.
Conditional Content is a powerful system plugin that provides tags that can be used to or {hide} special content. When you login to create an article, there will be an editor button underneath the article. You can use this editor button to wrap your content with the conditional tags needed for the desired results.
Here's where the editor button will appear:
After clicking the button, you'll will see the modal that's in the image below. Conditional Content works with any type of content, including text, images, and code like HTML. Simply, enter your content and specify if you want to show or hide it.
Here's an example of the Conditional Content text in action. This code will only show for Guests, and no-one else will see it:
{show access="Guest"}You are not logged in yet!
Here are a few creative examples that show off what you can accomplish with Conditional Content.
You can display a message only to visitors from North America:
Product colour: Red
You can render a mobile optimized image for all visitors viewing from a mobile device:
img src=/images/new-joomlashack-blog.jpg"
You can ask guest visitors to subscribe to your newsletter, while showing logged users a special offers link:
<a href="/subscribe">Subscribe</a>
As you can see in the example above, Conditional Content offers the ability to display alternative content when specified conditions are not met.
In other words, it’s an "if else" function that works for scenarios when you're either showing or hiding content.
The plugin provides an extensive selection of conditions that can be activated if ALL or ANY conditions are met. Here is a list of the available conditional parameters for the Free and Pro versions:
- Home Page
- Menu Items
- Date Range
- User Group Levels
- Languages
- Devices
And here are the more advanced parameters available in the Pro version of Conditional Content:
- Extra fields
- Seasons, Months, Days, Time
- Users
- Geolocating
- Templates
- URLs
- Operating Systems
- Browsers
- Components
- Tags
- Joomla! Content
- Custom PHP
Note: each condition offers three parameter states: Ignore (default state), Include, and Exclude. If you've used other Regular Labs extensions such as Advanced Module Manager, then you will very much at home with Conditional Content.
Pro Tip: Caching
Conditional Content can be effected by caching systems. Some conditions more than others. For example, the conditions: Menu Items, Home page, Extra fields, Tags, Templates are minimally impacted by cache. However, conditions such as Users, Geolocation, and Browsers can be greatly affected when cache is implemented.
Enabling "Platform Specific Caching" in your site's Global Configuration will make sure that Conditional Content works correctly.
Conclusion
Once you install Regular Labs Conditional Content you will quickly realize the additional control it provides your Joomla! website. Best of all, Conditional Content is flexible and easy to implement.
Show some Joomla! love by rating Conditional Content on the Joomla! Extension Directory. Post a comment with your thoughts and use cases. We would love to hear from you!