The expinfo operator
expinfo answers "which extensions are installed, which are active, and what version is this?" from a template. It is
registered by eZTemplateExpInfoOperator (lib/eztemplate/classes/eztemplateexpinfooperator.php) through
lib/eztemplate/classes/eztemplateautoload.php, and reads everything through the class expInfo
(lib/ezutils/classes/expinfo.php).
Contents
expinfo
expinfo
The mode is the first parameter, or the piped string when there is no parameter:
| Mode | Returns (expInfo method) |
|---|---|
none, '' or 'active' | a hash of the active extensions, name to info (activeExtensions()) |
'all' | every available extension, each with active true or false (availableExtensions()) |
'kernel' | the kernel information (kernelInfo()) |
| an extension name | that extension's info with active, or false when it does not exist (extensionInfo()) |
| Parameter | Type | Required | Default |
|---|---|---|---|
| mode or extension name | string | no | active extensions |
There are no named parameters. Generated reference: expinfo.
One extension
The info of an extension is built from its extension.xml and its ezinfo.php (the <extension>Info::info() array),
plus mtime, mtime_formatted, extension_name and active. Keys that an ezinfo.php adds, such as the
third-party software notes of ezjscore, appear under their own names:
def $ext = expinfo( 'ezjscore' )
if $extkeys: foreach $ext as $key => $value$keydelimiter, /delimiter/foreach
ezjscore $ext.version, license: $ext.license|wash, active: $ext.active|choose( 'no', 'yes' )/if
expinfo( 'no_such_extension' ) = [expinfo( 'no_such_extension' )|choose( 'false', 'true' )]Output:
keys: name, version, copyright, license, info_url, Includes the following third-party software, Includes the following third-party software (2), Includes the following third-party software (3), mtime, mtime_formatted, extension_name, description, summary, author, meta, active
ezjscore 1.8.5, license: GNU General Public License v2.0 (or any later version), active: yes
expinfo( 'no_such_extension' ) = [false]{if expinfo( 'name' )} is a safe way to make a template part depend on an extension being installed; test .active
too when the extension must also be switched on.
Lists of extensions
{def $active = expinfo()
$all = expinfo( 'all' )
$piped = 'ezjscore'|expinfo
$inactive = 0}
foreach $all as $name => $infoif $info.active|notset $inactive = $inactive|inc/if/foreach
expinfo() returns $active|count active extensions; expinfo( 'all' ) returns $all|count, of which $inactive are not active.
'ezjscore'|expinfo works too: $piped.name|washOutput:
expinfo() returns 62 active extensions; expinfo( 'all' ) returns 87, of which 25 are not active.
'ezjscore'|expinfo works too: eZ JSCore LSAttribute access on the result works on a variable ($piped.name), but not directly after an operator applied to a
literal: {'ezjscore'|expinfo.name} is a parser error ("Extra characters found in expression"). Assign the result
first, as above.
The kernel
expinfo( 'kernel' ) returns a large hash, built once per request (buildKernelInfo()):
def $k = expinfo( 'kernel' )
sections: foreach $k as $section => $value$sectiondelimiter, /delimiter/foreach
version keys: foreach $k.version as $key => $value$keydelimiter, /delimiter/foreach
PHP sapi in this run: $k.php.sapiOutput:
sections: version, php, memory, server, database, ini, user, extensions, cache, filesystem, timestamps, git, composer
version keys: major, minor, release, state, development, alias, edition, full, full_alias
PHP sapi in this run: cliThe version section is meant for templates: $k.version.full is the release, as a string. The
other sections describe the server: server includes the host name, document root and installation paths, php
includes uname and the loaded extensions, database includes the database name, server and user (the password is
replaced by ***), and git and composer the state of the checkout. Never print those sections on a page that
visitors can see; they are for administration pages behind a login. The examples on this page print only section
and key names, and the PHP SAPI of the command-line run.
All examples gave the same output interpreted and compiled on a development installation.
Related pages
- Extension anatomy:
ezinfo.phpandextension.xml - What an extension is
- Finding the extensions on your site
- All template operators (generated)
- Free documentation: this page is free to copy, translate and improve under the GNU FDL 1.3.
Become an Exponential Partner
Partners share their information, provide funding, contribute back and develop the products with us, and that is how Exponential grows. A partner website and dashboard are planned for mid-2027: please become a partner today to speed up our growth rate and land new features faster.