With the Pro version of Content Templater, you can access the "Conditions" tab in the item edit.
By using the Conditions, you can determine where a template is available, either via the editor buttons or when automatically loaded.
Available Conditions include virtually anything, including Menu Items, Categories, Dates, Users, Devices, Geolocation, Components, Templates, URLs, and much more.
This way you can - for example - create templates only for certain user groups. Or only available during certain seasons. Or only within certain extensions (components).
You can create re-usable Conditions Sets that can be shared by multiple templates, and even across different Regular Labs extensions like Advanced Module Manager, ReReplacer, and Conditional Content.
If no Condition Set is selected, or if a Condition Set has no rules, the template will be available everwhere on your site. As soon as you set one or more of the rules to Include
or Exclude
, the template will be limited to the pages/situations matching those rules.
Rules & Groups
Each Condition Set is made up of one or more Groups and Rules. This makes it incredibly flexible and versatile.
You can select your desired rules via a dropdown menu, adding more via the + Add Rule button, or removing existing ones via the - button.
You can use the same Rule type more than once, and you have the ability to combine different Matching Methods (AND/OR) by putting rules into Groups.
When you have more than one Rule in a Group, you will see a Matching Method inside that Group. And if you have more than one Group, you will also see a Matching Method at the top.
When selecting rules in a Condition Set, a nice Summary will be displayed on the right, showing you a recap of where the module will appear on the site.
If no Condition Set is selected for a module, or if a Condition Set has no rules, the module will be shown on all pages of your website (that include the module position). As soon as you set one or more of the rules to Include
or Exclude
, the module will be limited to the pages/situations matching those rules.
Matching Method
You can of course use and combine any of the available rules.
To control how multiple rules are applied, there is a Matching Method option. This determines whether all or any of the rules need to be matched:
- ALL: Will be published if ALL of the selected rules are matched at the same time.
- ANY: Will be published if ANY (one or more) of the selected rules are matched at any time.
Note: When setting multiple rules to Exclude
, the Matching Method should be set to ALL
. Otherwise, using ANY
would result in one Exclude condition to always match and the template to show everywhere else.
You can also combine and use different Matching Methods by adding multiple Groups of rules: you can set a global Matching Method for the groups, and an individual Matching Method for the rules in each group.
Rules States
When selecting a rule, you can give it two possible states/options:
- Include: the template will be included in all pages that do match that rule
- Exclude: the template will be included in all pages that do not match that rule
Menu Items
Set the template to be included or excluded from any of the available menu items.
Also on Child Items
This option allows you to make the rule pass on menu items that are children of one of the selected menu items.
This is very useful when you regularly add menu items and don't want to update the Condition Set every time. Just select the parent menu item.
Home Page
Unlike selecting the home page (default) item via the Menu Items, this will only match the real home page, not any URL that has the same Itemid as the home menu item.
This might not work for all 3rd party SEF extensions.
Date & Time
The date and time rules use the date/time of your servers, not the ones of the visitor's system.
Date
You can make the rule pass Before/After a specific date or, with the "Between" option, in a date range between two dates.
With the "Recurring" option, you can also select to apply the date range every year (so the year in the selection will be ignored).
Seasons
You can choose from these options:
Winter, Spring, Summer, Fall / Autumn
You can also select the hemisphere your website is located in:
Northern, Southern, Australia.
Months
You can choose from these options:
January, February, March, April, May, June, July, August, September, October, November, December
Days of the week
You can choose from these options:
Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday
Time
You can make the rule pass Before/After a specific time or, with the "Between" option, in a time range between two times.
Format: 23:59
Joomla! Content
This rule is based on what Joomla content page is displayed, including Page Types, Categories, and specific Articles.
Page types
You can choose from these options:
Archived Articles, Single Article, List All Categories, Category Blog, Category List, Featured Articles, Create Article
Categories
Set the template to be included or excluded from any of the Joomla categories.
Also on Child Items
This option allows you to make the rule pass on categories that are children of one of the selected categories.
This is very useful when you regularly add categories and don't want to update the Condition Set every time. Just select the parent category.
Page Types
This option allows you further narrow the rule, to make it only pass on certain page types: Categories, Articles, Others.
Articles
Set the template to be included or excluded from any of the Joomla articles.
Featured Articles
Set the template to be included or excluded from Featured articles.
Article Publish State
Set the template to be included or excluded from the available article publish states:
You can choose from these options:
Published, Unpublished, Archived, Trashed
Article Date
Set the template to be included or excluded based on any of these article dates: Created Date, Modified Date, Start Publishing, Finish Publishing
After selecting a Date Type, you can make the rule pass Before/After a specific date or, with the "Between" option, in a date range between two dates.
With the "Recurring" option, you can also select to apply the date range every year (so the year in the selection will be ignored).
Article Authors
Set the template to be included or excluded from articles written by specific authors.
Article Content Keywords
Set the template to be included or excluded from articles containing your specified keywords in the content.
You can also turn on the 'Case Sensitive' option.
Article Meta Keywords
Set the template to be included or excluded from articles containing your specified meta keywords.
You can also turn on the 'Case Sensitive' option.
Article Field
Set the template to be included or excluded based on the value of any Custom Field.
You can compare the custom field value with any of these methods:
Is equal to, Is not equal to, Contains, Contains one of, Does not contain, Begins with, Ends with, Is less than, Is greater than, Matches Regular Expressions
For complete details on how to use the Custom Fields rules, the Comparison Methods, and even how to use Relative Dates as part of your checks, see the dedicated Blog Post.
Visitors
Users
Set the template to be included or excluded based on the logged-in user visiting the page.
Access Levels
Set the template to be included or excluded based on the Access Level assigned to the logged-in user visiting the page.
User Groups
Set the template to be included or excluded based on the user group assigned to the logged-in user visiting the page.
Match all
Select to only let the rule pass if all of the selected user groups belong to the user at the same time.
Also on Child Items
This option allows you to make the rule pass on user groups that are children of one of the selected groups.
This is very useful when you regularly add user groups and don't want to update the Condition Set every time. Just select the parent user group.
Languages
Set the template to be included or excluded based on the site Language used by the visitor.
This Languages rule differs from the core in that it allows a selection of multiple languages.
Devices
Set the template to be included or excluded based on the device of the visitor. Keep in mind that device detection is not always 100% accurate. Users can set up their devices to mimic other devices.
You can choose from these options:
Desktop, Tablet, Mobile
Operating Systems
Set the template to be included or excluded based on the operating system of the visitor. Keep in mind that operating system detection is not always 100% accurate. Users can set up their browsers to mimic other operating systems.
Browsers
Set the template to be included or excluded based on the browser of the visitor. Keep in mind that browser detection is not always 100% accurate. Users can set up their browsers to mimic other browsers
Mobile Browsers
Set the template to be included or excluded based on the mobile browser of the visitor. Keep in mind that browser detection is not always 100% accurate. Users can set up their browser to mimic other browsers
IP Addresses
Set the template to be included or excluded based on the IP Address of the visitor.
You can enter a comma and/or enter a separated list of IP addresses and IP ranges. For instance:
127.0.0.1
128.0-128.1
129
Geolocation
Geolocating is not always 100% accurate. The geolocation is based on the IP address of the visitor. Not all IP addresses are fixed or known.
To be able to use this rule, you need to install the Regular Labs GeoIP library.
Continents
Set the template to be included or excluded based on the Continent of the visitor.
Countries
Set the template to be included or excluded based on the Country of the visitor.
Regions
Set the template to be included or excluded based on the Region / State of the visitor.
Postal Codes
Set the template to be included or excluded based on the Postal Code of the visitor.
You can enter a comma-separated list of postal codes (12345) or postal code ranges (12300-12500).
Miscellaneous
Tags
Set the template to be included or excluded from any of the Joomla tags or tagged pages.
Match all
Select to only let the rule pass if all of the selected tags belong to the page at the same time.
Also on Child Items
This option allows you to make the rule pass on tags that are children of one of the selected tags.
This is very useful when you regularly add tags and don't want to update the Condition Set every time. Just select the parent tag.
Components
Set the template to be included or excluded from specific Components.
Templates
Set the template to be included or excluded from specific Templates.
URLs
The URL rule allows control over specific pages or groups of pages, with support for Regular Expressions.
You can enter (part of) the URLs to match, by using a new line for each different match.
You can also turn on the 'Case Sensitive' option, or select to treat the value as Regular Expressions.
Custom PHP
This gives you the opportunity to show or hide a template based on anything you can think of. You just need to know what PHP code you should use.
With PHP you can call on all data/information available in the variables, URL, database, etc. And then do your checks on this data. You can control the display by ending the PHP code with a return true or false based on your checks.
For examples and ready-to-use PHP scripts, check out the "Using Custom PHP Conditions" guide.
Other Condition Set
You can also nest another existing Condition Set as part of the current Condition Set.
This allows you to add (or exclude) a set of rules from another Condition Set on top of the current Condition Set.
HikaShop
This rule is based on what HikaShop page is displayed, including Page Types, Categories, and Products.
Page types
You can choose from these options:
Author's items, Category, Categories, Content item, Favoured Items (category view), Favoured Items (legacy view), My Items, Search, Tagged Items (category view), Tagged Items (legacy view)
Categories
Set the template to be included or excluded from any of the HikaShop categories.
Also on Child Items
This option allows you to make the rule pass on categories that are children of one of the selected categories.
This is very useful when you regularly add categories and don't want to update the Condition Set every time. Just select the parent category.
Page Types
This option allows you further narrow the rule, to make it only pass on certain page types: Categories, Products.
Products
Set the template to be included or excluded from any of the HikaShop products.
FLEXIcontent
This rule is based on what FLEXIcontent page is displayed, including Page Types, Tags, and FLEXIcontent Types.
Page types
You can choose from these options:
Author's items, Category, Categories, Content item, Favoured Items (category view), Favoured Items (legacy view), My Items, Search, Tagged Items (category view), Tagged Items (legacy view)
Tags
Set the template to be included or excluded from any of the FLEXIcontent tags.
Page Types
This option allows you further narrow the rule, to make it only pass on certain page types: Tags, Items.
Types
Set the template to be included or excluded from any of the FLEXIcontent types.