With the recent release of October CMS v3.0, this advice should help with managing plugins across multiple versions. To use different logic depending on the October CMS version. Here is a way for you to check the exact version.
A simple way to check if October CMS is running v2 or above:
if (class_exists('System')) {
// Running October CMS 2.0 or above
}
else {
// Running October CMS 1.0 or 1.1
}
For more precise checking, you can include an extra step with version_compare
. This next example checks if it is running v2.2 or above:
if (
class_exists('System') &&
version_compare(\System::VERSION, '2.2', '>=')
) {
// Running October CMS 2.2 or above
}
else {
// Running a legacy version
}
Another example:
if (!class_exists('System')) {
// Running October CMS 1.0 or 1.1
}
// 2.0 only
elseif (version_compare(\System::VERSION, '2.0', '=')) {
// Running October CMS 2.0 only (not including 2.1, 2.2, etc.)
}
This is the strategy we use internally with the RainLab plugins. I hope you find this useful as well.