Feature #19739
closedTypoScript Condition to check for installed extensions
Added by Franz Holzinger almost 16 years ago. Updated almost 10 years ago.
0%
Description
It is sometimes necessary to give a different setup if an additional extension has been installed. This could be to enable the setup for a new field which has been added to an extension. You must not have this setup if the extension is not installed. This will make it possible to write a common TypoScript which can be used on different sites with different installed extensions.
ext
Syntax:
[ext = extension1,extension2, ...]
Extension:
This checks if an extension has been installed. Only in this case the following TypoScript will apply.
(issue imported from #M10011)
Files
matchcondition.diff (537 Bytes) matchcondition.diff | Administrator Admin, 2008-12-24 11:02 | ||
path_10011_4.3.diff (677 Bytes) path_10011_4.3.diff | Administrator Admin, 2009-07-31 16:08 | ||
10011.diff (7.22 KB) 10011.diff | Administrator Admin, 2010-08-24 18:45 |
Updated by Sven Burkert over 14 years ago
I missed that TS condition, too.
In my ext. "rtelightbox" I solved this with a user-function:
TypoScript:
[userFunc = user_isLoaded(wsclicklightbox)]
...
ext_localconf.php:
/**
* Check if an extension is installed
*
* @param string $extKey: Key of extension
* @return boolean
*/
if (!function_exists('user_isLoaded')) {
function user_isLoaded($extKey) {
if (t3lib_extMgm::isLoaded($extKey)) {
return true;
}
return false;
}
}
Updated by Chris topher over 14 years ago
Hi Sven,
thanks for your hint.
Could you have a look at this thread in core list and give your +1, if the patch works for you?
Updated by Franz Holzinger over 14 years ago
See the extension patch10011 which contains an improved version of this patch.
Updated by Jo Hasenau over 14 years ago
Just FYI: We already got globalString, which can use a regular expression on
TSFE:TYPO3_CONF_VARS|EXT|extList_FE
Updated by Chris topher over 14 years ago
So there is an extension which can achieve this and (even better) it already is possible with "Core only".
I think we then don't need this fix anymore...
Updated by Sven Burkert over 14 years ago
I've seen a nice solution in Ext. "perfectlightbox":
[globalString = TYPO3_LOADED_EXT|tt_news|type=*]
Updated by Sven Burkert over 14 years ago
Errr, perhaps this condition is wrong (is it?): In my TYPO3 environment (Version 4.3.3) the condition is always true.
Perhaps this is the correct condition:
[globalString = TYPO3_LOADED_EXT|tt_news|type=/(.+)/]
Updated by Franz Holzinger over 14 years ago
A check for an installed extension is not enough. In many cases you must also verify the version number of the installed extension.
Updated by Xavier Perseguers over 13 years ago
- Target version deleted (
4.6.0-beta1)
Updated by Mathias Schreiber almost 10 years ago
- Status changed from New to Closed
You can now ship your own custom userfunctions for conditions.
They are very easy to use and can contain more logic than the core can offer.
Updated by Alexander Opitz almost 10 years ago
Franz Holzinger wrotes to ML:
Please open bug #19739 (former #10011) https://forge.typo3.org/issues/19739 Reason: The patch is there and working (since more than 6 years). Many users wanted this feature. Therefore I have written this patch. It needs modifications in the TYPO3 Core. Therefore it cannot be easily added as a standalone extension (maybe breaking something else). The arguments to close this issue are wrong. - Franz
Updated by Benni Mack almost 10 years ago
Hey Franz,
I really don't see this "required" for the core. This are the reasons why:
1. If you need to ship custom TypoScript code based if an extension is loaded, this should be done in ext_localconf.php with certain conditions. Why? Adding a lot of TypoScript conditions (even shipped with an extension) leads to a lot of multiple caching, thus I'm against using TS condition a lot.
2. Checking for an extension should be done at ext_localconf.php time. E.g. A lightbox extension ships an adaption for tt_content and tt_news, adding TypoScript as static includes, for each extension. This is how most people do it these days, or with options in Constant Editor.
3. I have - seriously - quite some TS conditions that are great for our projects. But: I can register my own now, in a very nice way and ship it as an extension, which I do.
I hope the ext_localconf.php solution works for your needs.
All the best,
Benni.
Updated by Franz Holzinger almost 10 years ago
Hello Benjamin,
there are some users who needed this already in the year 2008 and have given comments on the old bug tracker. Most TYPO3 users do not want to modify the PHP files shipped in the TYPO3 extensions. And it is not recommended at all to modify them. They would have to write their own extensions. But it would be much easier to add a simple line of a TypoScript Condition. Is this understandable?
- Franz
Updated by Philipp Gampe almost 10 years ago
You can release a user condition as extension:
http://docs.typo3.org/typo3cms/TyposcriptSyntaxReference/TypoScriptParserApi/CustomConditions/Index.html
Updated by André Wuttig almost 10 years ago
[userFunc = TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('ext_key')] ... [global]
Updated by Martin Bless almost 10 years ago
Hi André, very good tip.
Note that the extkey must be prefixed by 'tx_'. I just ran into this:
[userFunc = TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('tx_' . $extKey)] ... [global]
Updated by Sven Burkert almost 10 years ago
Hi Martin,
you are not in PHP context, so $extKey seems a bit confusing.
I've testet it with TYPO3 6.2, the only working solution is
userFunc = TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('ext_key')]
And function "isLoaded" says:
/** * Returns TRUE if the extension with extension key $key is loaded. * * @param string $key Extension key to test * @param boolean $exitOnError If $exitOnError is TRUE and the extension is not loaded the function will die with an error message * @return boolean * @throws \BadFunctionCallException */ static public function isLoaded($key, $exitOnError = FALSE) {