Project

General

Profile

Actions

Feature #19739

closed

TypoScript Condition to check for installed extensions

Added by Franz Holzinger over 15 years ago. Updated about 9 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2008-12-24
Due date:
% Done:

0%

Estimated time:
PHP Version:
4.3
Tags:
Complexity:
Sprint Focus:

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

Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Bug #22553: t3lib_extMgm should provide API to determine whether ext is installed or notClosed2010-04-30

Actions
Actions #1

Updated by Sven Burkert almost 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;
}
}

Actions #2

Updated by Chris topher almost 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?

Actions #3

Updated by Franz Holzinger almost 14 years ago

See the extension patch10011 which contains an improved version of this patch.

Actions #4

Updated by Jo Hasenau almost 14 years ago

Just FYI: We already got globalString, which can use a regular expression on

TSFE:TYPO3_CONF_VARS|EXT|extList_FE

Actions #5

Updated by Chris topher almost 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...

Actions #6

Updated by Sven Burkert almost 14 years ago

I've seen a nice solution in Ext. "perfectlightbox":
[globalString = TYPO3_LOADED_EXT|tt_news|type=*]

Actions #7

Updated by Sven Burkert almost 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=/(.+)/]

Actions #8

Updated by Franz Holzinger almost 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.

Actions #9

Updated by Xavier Perseguers over 12 years ago

  • Target version deleted (4.6.0-beta1)
Actions #10

Updated by Mathias Schreiber over 9 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.

Actions #11

Updated by Alexander Opitz over 9 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 

Actions #12

Updated by Benni Mack over 9 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.

Actions #13

Updated by Franz Holzinger over 9 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

Actions #15

Updated by André Wuttig about 9 years ago

[userFunc = TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('ext_key')]

...

[global]
Actions #16

Updated by Martin Bless about 9 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]
Actions #17

Updated by Sven Burkert about 9 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) {

Actions

Also available in: Atom PDF