Constants - phpManufaktur/kfTemplateTools GitHub Wiki

The following constants are available if you are using the TemplateTools.

You can access each of this constants in PHP notation, i.e.:

<?php echo CMS_LOCALE; ?>

or within a Twig template as variable, i.e.:

{{ CMS_LOCALE }}

The TemplateTools provide you with constants for different purposes:

  1. CMS Constants
  2. Page Constants
  3. Template Constants
  4. show_menu2() Constants
  5. Browser Constants
  6. kitFramework Constants
  7. Extra Constants

##CMS constants

CMS constants affect the whole Content Management System an not only a single page:

###CMS_ADDONS_PATH

Return the full path to the addons (module) directory.

###CMS_ADDONS_URL

Return the URL to the addons (module) directory.

###CMS_DESCRIPTION

Return the Website Description, defined in the CMS settings.

###CMS_KEYWORDS

Return the Website Keywords, defined in the CMS settings.

###CMS_LOCALE

Return the default locale for the Content Management System defined in the CMS settings in lowercase, i.e. de (German).

CMS_LOCALE is comparable to the WebsiteBaker constant DEFAULT_LANGUAGE.

Attention: This is not the locale for the current page!

See also: PAGE_LOCALE

###CMS_LOGIN_ENABLED

Return boolean true if the frontend login is enabled - see settings in the backend: login -> enabled.

###CMS_LOGIN_FORGOTTEN_URL

Return the URL to redirect the user to, if he had forgotten his password.

If CMS_LOGIN_ENABLED == false this constant will return the CMS_URL.

###CMS_LOGIN_REDIRECT_URL

Return the URL to redirect the user after a successful login. This can be the start page but also the URL the user tried to access before he was authenticated.

###CMS_LOGIN_SIGNUP_ENABLED

Return boolean true if the frontend signup is enabled - see settings in the backend: sign-up -> member group.

###CMS_LOGIN_SIGNUP_URL

Return the URL with the signup dialog.

If CMS_LOGIN_SIGNUP_ENABLED == false this constant will return the CMS_URL.

###CMS_LOGIN_URL

Return the URL for the login check.

If CMS_LOGIN_ENABLED == false this constant will return the CMS_URL.

###CMS_LOGOUT_URL

Return the URL to logout the user.

If CMS_LOGIN_ENABLED == false this constant will return the CMS_URL.

###CMS_MAINTENANCE_MODE

Return true if the maintenance mode is activated.

You can use the maintenance mode to lock the website temporarily for visitors. Activate the maintenance mode by using the page_option() feature and set the option:

[maintenance:true]

to the keywords field of the Home page (the first page a visitor will see, identified by PAGE_ID_HOME.

To disable the maintenance mode remove the option or set the value to false:

[maintenance:false]

Example php:

The best place is at the top of your index.php:

<?php
    // initialize the TemplateTools
    require_once WB_PATH.'/kit2/extension/phpmanufaktur/phpManufaktur/TemplateTools/initialize.php';  
    
    if (!CMS_MAINTENANCE || (CMS_MAINTENANCE && CMS_USER_IS_ADMIN)) {
        // show the template
        $template['twig']->display('twig/template.twig');
    }
    else {
        // show the maintenance message
        $template['twig']->display('@pattern/bootstrap/maintenance.twig');
    }
?>    

In this example all visitors will see the maintenance screen, but a authenticated administrator has full access to the website an can implement, view and test all changes he want to process.

###CMS_MEDIA_PATH

Return the full path to the media directory of the CMS.

###CMS_MEDIA_URL

Return the URL to the media directory of the CMS.

###CMS_MODIFIED_BY

Return the displayname of the user who has last modified any page of the Content Management System (CMS).

###CMS_MODIFIED_WHEN

Return the date and time for the last modification of any page of the Content Management System (CMS) in format Y-m-d H:i:s

See also: PAGE_MODIFIED_WHEN

###CMS_PAGES_DIRECTORY

Return the directory name for the CMS pages, by default this is /pages for WebsiteBaker and /page for LEPTON CMS and BlackCat CMS.

###CMS_PATH

Return the full path to the root directory of the CMS.

This constant is comparable to the CMS constants WB_PATH, LEPTON_PATH or CAT_PATH.

See also: CMS_URL

###CMS_SEARCH_VISIBILITY

Return the visibility of the CMS search function, possible values are: public, private, registered and none.

###CMS_TABLE_PREFIX

Return the MySQL table prefix which is used by the CMS, by default wb_, lep_ or cat_.

See also: FRAMEWORK_TABLE_PREFIX

###CMS_TEMPLATES_PATH

Return the full path to the /templates directory of the CMS.

See also: TEMPLATE_PATH.

###CMS_TEMPLATES_URL

Return the URL to the /templates directory of the CMS.

See also: TEMPLATE_URL.

###CMS_TITLE

Return the Website Title, defined in the CMS settings.

###CMS_TYPE

Return the CMS type, the value can be WebsiteBaker, LEPTON or BlackCat.

See also: CMS_VERSION

###CMS_URL

Return the URL to the root directory of the CMS.

This constant is comparable to the CMS constants WB_URL, LEPTON_URL or CAT_URL.

###CMS_USER_ACCOUNT_URL

Return the URL to the dialog to change the user account setting, the user must be authenticated to access this dialog.

If CMS_LOGIN_ENABLED == false this constant will return the CMS_URL.

###CMS_USER_DISPLAY_NAME

Return the display name (full name) of the authenticated user or anonymous for any other user.

###CMS_USER_EMAIL

Return the email address of the authenticated user or an empty string for any other user.

###CMS_USER_GROUP_IDS

If the user is authenticated this constant return a string with the comma separated group ID's to which the user belong to, otherwise an empty string.

Use the php function explode() or the twig Filter split to use this value as array.

###CMS_USER_GROUP_NAMES

If the user is authenticated this constant return a string with the comma separated group names to which the user belong to, otherwise an empty string.

Use the php function explode() or the twig Filter split to use this value as array.

###CMS_USER_ID

Return the ID of the authenticated user or -1 for any other user.

###CMS_USER_IS_ADMIN

Return true if the user is authenticated and has administrator permissions.

###CMS_USER_IS_AUTHENTICATED

Return boolean true if the user is authenticated or false in any other case.

###CMS_USER_USERNAME

Return the username (the name for the login) of the authenticated user or anonymous in any other case.

###CMS_VERSION

Return the version number of the used CMS.

See also: CMS_TYPE

##Page constants

These constants describe the properties of the current page.

###PAGE_DESCRIPTION

Return the page description.

See also page_description().

###PAGE_EXTENSION

Return the used page extension, including the dot. By default the extension is .php

###PAGE_FOOTER

Return the parsed page footer, defined in the CMS settings.

See also page_footer().

###PAGE_HAS_CHILD

Return boolean true if the current page has a child or children and false if not.

###PAGE_HEADER

Return the page header, defined in the CMS settings.

See also page_header().

###PAGE_ID

Return the ID of the current page.

###PAGE_ID_HOME

Return the PAGE_ID of the first, the home page.

###PAGE_KEYWORDS

Return the defined page keywords.

See also page_keywords().

###PAGE_LOCALE

Return the locale for the current page in lowercase, i.e. de for German.

This constant is comparable with the WebsiteBaker constant LANGUAGE.

See also: CMS_LOCALE

###PAGE_MENU_LEVEL

Return the actual level of the page in the menu structure, starting with 0 (top level).

###PAGE_MENU_TITLE

Return the title defined for the menu.

###PAGE_MODIFIED_BY

Return the display name of the person who has at last changed the current page.

See also:

###PAGE_MODIFIED_WHEN

Return the date in format y-m-d H:i:s for the last change of the current page.

In php use the date() function to get a localized date and time format:

date($template['translator']->trans(DATETIME_FORMAT), PAGE_MODIFIED_WHEN);

in a Twig template use the date filter:

{{ PAGE_MODIFIED_WHEN|date(DATETIME_FORMAT|trans) }}

this will return for a German (de) localized page for example:

12.04.2014 - 12:32

See also:

###PAGE_PARENT_ID

Return the PAGE_ID of the parent for the current page. If the page has no parent (reside at top level) PAGE_PARENT_ID will return 0.

###PAGE_TITLE

Return the title of the current page.

See also page_title().

###PAGE_URL

Return the URL of the current page.

###PAGE_VISIBILITY

Return the visibility of the current page, this can be:

  • public - visible for everyone
  • private - only for the author of the page
  • hidden - hidden (not listed in the navigation)
  • registered - only for registered users
  • none - none, will not shown

##Template constants

These constants describe the template:

###TEMPLATE_DEFAULT_NAME

Return the template name of the as default defined template.

###TEMPLATE_DIRECTORY

Return the directory name where the actual template reside.

###TEMPLATE_NAME

Return the name of the actual template.

###TEMPLATE_PATH

Return the full path to the actual template.

###TEMPLATE_URL

Return the URL to the actual template.

##show_menu2() constants

These constants are used by show_menu2() and generally available in all php scripts. The TemplateTools make these constants also available in all Twig template files *.twig.

  • SM2_ALL
  • SM2_ALLINFO
  • SM2_ALLMENU
  • SM2_BUFFER
  • SM2_COND_TERM
  • SM2_CONDITIONAL
  • SM2_CRUMB
  • SM2_CURR
  • SM2_CURRTREE
  • SM2_ESCAPE
  • SM2_MAX
  • SM2_NO_TITLE
  • SM2_NOCACHE
  • SM2_NOESCAPE
  • SM2_NUMCLASS
  • SM2_PRETTY
  • SM2_ROOT
  • SM2_SHOWHIDDEN
  • SM2_SIBLING
  • SM2_START
  • SM2_TRIM
  • SM2_XHTML_STRICT

Please have a look to the show_menu2() documentation to get more information about the usage of show_menu2().

ATTENTION: show_menu2() is using the bitwise or Operator | (pipe) to combine flags. You can not use the pipe | as bitwise or Operator in Twig, you must use b-or instead!

Example, if you need something like:

{{ show_menu2(0, SM2_ROOT, SM2_ALL, SM2_ALL|SM2_NUMCLASS|SM2_PRETTY) }}

you must use instead:

{{ show_menu2(0, SM2_ROOT, SM2_ALL, SM2_ALL b-or SM2_NUMCLASS b-or SM2_PRETTY) }}

See also CMS Service show_menu2()

##Browser Constants

These constants are used by the Browser Service.

Identify the used Browser:

  • BROWSER_AMAYA => Amaya
  • BROWSER_ANDROID => Android
  • BROWSER_BINGBOT => Bing Bot
  • BROWSER_BLACKBERRY => BlackBerry
  • BROWSER_CHROME => Chrome
  • BROWSER_FIREBIRD => Firebird
  • BROWSER_FIREFOX => Firefox
  • BROWSER_GALEON => Galeon
  • BROWSER_GOOGLEBOT => GoogleBot
  • BROWSER_ICAB => iCab
  • BROWSER_ICECAT => IceCat
  • BROWSER_ICEWEASEL => Iceweasel
  • BROWSER_IE => Internet Explorer
  • BROWSER_IPAD => iPad
  • BROWSER_IPHONE => iPhone
  • BROWSER_IPOD => iPod
  • BROWSER_KONQUEROR => Konqueror
  • BROWSER_LYNX => Lynx
  • BROWSER_MOZILLA => Mozilla
  • BROWSER_MSN => MSN Browser
  • BROWSER_MSNBOT => MSN Bot
  • BROWSER_NETPOSITIVE => NetPositive
  • BROWSER_NETSCAPE_NAVIGATOR => Netscape Navigator
  • BROWSER_NOKIA => Nokia Browser
  • BROWSER_NOKIA_S60 => Nokia S60 OSS Browser
  • BROWSER_OMNIWEB => OmniWeb
  • BROWSER_OPERA => Opera
  • BROWSER_OPERA_MINI => Opera Mini
  • BROWSER_PHOENIX => Phoenix
  • BROWSER_POCKET_IE => Pocket Internet Explorer
  • BROWSER_SAFARI => Safari
  • BROWSER_SHIRETOKO => Shiretoko
  • BROWSER_SLURP => Yahoo! Slurp
  • BROWSER_UNKNOWN => unknown
  • BROWSER_W3CVALIDATOR => W3C Validator
  • BROWSER_WEBTV => WebTV

Identifiy the used platform:

  • PLATFORM_ANDROID => Android
  • PLATFORM_APPLE => Apple
  • PLATFORM_BEOS => BeOS
  • PLATFORM_BLACKBERRY => BlackBerry
  • PLATFORM_FREEBSD => FreeBSD
  • PLATFORM_IPAD => iPad
  • PLATFORM_IPHONE => iPhone
  • PLATFORM_IPOD => iPod
  • PLATFORM_LINUX => Linux
  • PLATFORM_NETBSD => NetBSD
  • PLATFORM_NOKIA => Nokia
  • PLATFORM_OS2 => OS/2
  • PLATFORM_OPENBSD => OpenBSD
  • PLATFORM_OPENSOLARIS => OpenSolaris
  • PLATFORM_SUNOS => SunOS
  • PLATFORM_UNKNOWN => unknown
  • PLATFORM_WINDOWS => Windows
  • PLATFORM_WINDOWS_CE => Windows CE

##kitFramework constants

These constants are assigned to the kitFramework and enable you to access many additional features for your Content Management System:

###EXTENSION_PATH

The full path to the kitFramework Library php extensions, these are i.e. Carbon (Date & Time functions) or the HTML Purifier (Standards-Compliant HTML Filtering) and many other extensions.

See also: EXTENSION_URL

###EXTENSION_URL

The URL to the kitFramework Library php extensions.

See also: EXTENSION_PATH

###FRAMEWORK_CACHE

If you are using the Twig Template Engine and the cache is enabled, all *.twig templates will be precompiled and directly loaded from the cache - this will speed up the output because the files are not parsed and compiled at each access.

By default the FRAMEWORK_CACHE is enabled and set to true.

While creating your template, the cache may ignore smaller changes, so switch off the cache when you are working at your templates.

The settings for the cache are defined in the framework.json configuration file.

You can override the settings if you define the FRAMEWORK_CACHE just before initializing the TemplateTools:

define('FRAMEWORK_DEBUG', true);
define('FRAMEWORK_CACHE', false);
require_once WB_PATH.'/kit2/extension/phpmanufaktur/phpManufaktur/TemplateTools/initialize.php';

See also: FRAMEWORK_DEBUG

###FRAMEWORK_DEBUG

If you are using the Twig Template Engine and the debug mode is enabled, Twig will check all variables in a strict mode and enable the additional Twig debugging functions like {{ dump() }}.

By default FRAMEWORK_DEBUG is disabled and set to false.

While you are developing your template, you should switch on the debugging mode.

The settings for the debugging are defined in the framework.json configuration file.

You can override the settings if you define the FRAMEWORK_DEBUG just before initializing the TemplateTools:

define('FRAMEWORK_DEBUG', true);
define('FRAMEWORK_CACHE', false);
require_once WB_PATH.'/kit2/extension/phpmanufaktur/phpManufaktur/TemplateTools/initialize.php';

See also: FRAMEWORK_CACHE

###FRAMEWORK_MEDIA_PATH

Return the full path to the public kitFramework media directory:

FRAMEWORK_PATH./media/public

See also: FRAMEWORK_MEDIA_URL, FRAMEWORK_PATH

###FRAMEWORK_MEDIA_URL

Return the URL to the public kitFramework media directory:

FRAMEWORK_URL./media/public

See also: FRAMEWORK_MEDIA_PATH, FRAMEWORK_URL

###FRAMEWORK_PATH

Return the full path to the kitFramework root directory.

See also: FRAMEWORK_URL

###FRAMEWORK_TABLE_PREFIX

Return the MySQL table prefix which is used by the kitFramework.

See also: CMS_TABLE_PREFIX

###FRAMEWORK_URL

Return the URL to the kitFramework root.

See also: FRAMEWORK_PATH

###HELPER_PATH

Return the full path to the kitFramework Library /Helper directory, which contains general helpers, i.e. for Bootstrap.

See also: HELPER_URL

###HELPER_URL

Return the URL to the kitFramework Library /Helper directory, which contains general helpers, i.e. for Bootstrap.

See also: HELPER_PATH

###LIBRARY_PATH

Return the full path to the kitFramework Library /Library directory, which contains different libraries, i.e. for jQuery, Bootstrap, Font Awesome and many other.

See also: LIBRARY_URL

###LIBRARY_URL

Return the URL to the kitFramework Library /Library directory, which contains different libraries, i.e. for jQuery, Bootstrap, Font Awesome and many other.

See also: LIBRARY_PATH

###MANUFAKTUR_PATH

Return the full path to the kitFramework directory, which contains the different extensions of the phpManufaktur for the kitFramework, i.e. the TemplateTools.

See also: MANUFAKTUR_URL

###MANUFAKTUR_URL

Return the URL to the kitFramework directory, which contains the different extensions of the phpManufaktur for the kitFramework, i.e. the TemplateTools.

See also: MANUFAKTUR_PATH

###THIRDPARTY_PATH

Return the full path to the kitFramework directory, which contains different extensions from third party vendors for the kitFramework.

See also: THIRDPARTY_URL

###THIRDPARTY_URL

Return the URL to the kitFramework directory, which contains different extensions from third party vendors for the kitFramework.

See also: THIRDPARTY_PATH

##Extra constants

The EXTRA_xxx constants are used for special purposes.

###EXTRA_FLEXCONTENT_ID

If the current page contains a flexContent article the EXTRA_FLEXCONTENT_ID return the ID of this flexContent article, i.e. for a database access. In any other case the EXTRA_FLEXCONTENT_ID will return -1.

###EXTRA_POST_ID

If the current page contain a News article, the EXTRA_POST_ID return the ID of this News article, i.e. for a database access or to set the page title. In any other case, the EXTRA_POST_ID will return -1.

###EXTRA_TOPIC_ID

If the current page contain a Topics article, the EXTRA_TOPIC_ID contain the ID of this Topics article, i.e. for a database access or to set the page title. In any other case, the EXTRA_TOPIC_ID will return -1.

Services Overview | Bootstrap Service