The target of the CMS Service is to grant the compatibility to the existing functions provided by the different Content Management Systems. If you have already created templates for [WebsiteBaker](http://websitebaker.org), [LEPTON CMS](http://leptopn-cms.org) or [BlackCat CMS](http://blackcat-cms.org) you will already know some of the following functions: * [`$template['cms']->cms_modified_by()`](#cms_modified_by) * [`$template['cms']->cms_modified_when()`](#cms_modified_when) * [`$template['cms']->page_content()`](#page_content) * [`$template['cms']->page_description()`](#page_description) * [`$template['cms']->page_footer()`](#page_footer) * [`$template['cms']->page_has_child()`](#page_has_child) * [`$template['cms']->page_header()`](#page_header) * [`$template['cms']->page_image()`](#page_image) * [`$template['cms']->page_keywords()`](#page_keywords) * [`$template['cms']->page_modified_by()`](#page_modified_by) * [`$template['cms']->page_modified_when()`](#page_modified_when) * [`$template['cms']->page_next_id()`](#page_next_id) * [`$template['cms']->page_option()`](#page_option) * [`$template['cms']->page_previous_id()`](#page_previous_id) * [`$template['cms']->page_sequence()`](#page_sequence) * [`$template['cms']->page_title()`](#page_title) * [`$template['cms']->page_url()`](#page_url) * [`$template['cms']->register_frontend_modfiles()`](#register_frontend_modfiles) * [`$template['cms']->register_frontend_modfiles_body()`](#register_frontend_modfiles_body) * [`$template['cms']->show_menu2()`](#show_menu2) * [`$template['cms']->wysiwyg_content()`](#wysiwyg_content) * [`$template['cms']->wysiwyg_section_ids()`](#wysiwyg_section_ids) most of these functions can directly prompt the result using `echo` (which is the general behavior of the origin functions provided by the different CMS), but they can also return the result without prompting. Some functions are new, like [`page_url()`](#page_url) and [`page_option()`](#page_option) or provide you with extended features like [`page_title()`](#page_title) or [`page_content()`](#page_content). All functions can also used within [[Twig Templates|Twig Service]], just place the function name between the delimiters `{{ ... }}`, for example: {{ page_content() }} ###`cms_modified_by()` Parameter * `string $locale` - optional, default = `null` * `boolean $prompt` - optional, default = `true` (`php` only) Usage `php` cms_modified_by(); ?> Usage `twig` {{ cms_modified_by() }} This function will return the displayname of the user who has last modified any page of the Content Management System (CMS). You can also specify the locale to use. See also * [`CMS_MODIFIED_BY`](Constants.md#cms_modified_by) * [`~~ cms_modified_by ~~`](kitCommands.md#cms_modified_by) * [`cms_modified_when()`](#cms_modified_when) * [`page_modified_by()`](#page_modified_by) ###`cms_modified_when()` Parameter * `string $format` - optional, default = `'DATETIME_FORMAT'` * `string $locale` - optional, default = `null` * `boolean $prompt` - optional, default = `true` (`php` only) Usage `php` cms_modified_when(); ?> Usage `twig` {{ cms_modified_when() }} This function will return the date and time of the last modification of any page in the Content Management System (CMS). You can also specify the format of the date and time stamp and the locale to use. Example `php`: cms_modified_when('Y-m-d'); ?> will return something like `2014-05-16`. The format can be a locale string which will be translated, i.e. from /kit2/extension/phpmanufaktur/phpManufaktur/Data/Locale/Metric like the predefined `'DATETIME_FORMAT'` or `'DATE_FORMAT'` or `'TIME_FORMAT'` or it can be any formatting string for the `php` function [`date()`](http://php.net/manual/en/function.date.php). See also * [`cms_modified_when()`](#cms_modified_when) * [`page_modified_by()`](#page_modified_by) * [`PAGE_MODIFIED_WHEN`](Constants.md#page_modified_when) * [`~~ page_modified_when ~~`](kitCommands.md#page_modified_when) ###`page_content()` Parameter * `integer|string $block` - optional, default = `1` * `boolean $prompt` - optional, default = `true` (`php`only) * `array $option` - optional, default = `array()` Usage `php` page_content(); ?> Usage `twig` {{ page_content() }} If you are using [content blocks](http://www.websitebaker.org/en/help/designer-guide/content-blocks.php?lang=EN) you can specify the block to prompt: page_content(2); ?> will prompt the second block defined in the `info.php` of the template. page_content(2, true, false); ?> will return the second block into the variable `$my_block` without prompting the content. In different to origin usage of the parameter `$block` you can also use the name of the block definition. If you `info.php` does contain: $block[1] = 'Main Content'; $block[2] = 'Sidebar'; you can also use: page_content('Sidebar'); ?> to load the content of the `Sidebar` block. This increase the readability of your templates. If you have installed [kitFramework imageTweak](https://kit2.phpmanufaktur.de/de/erweiterungen/imagetweak.php), the function `page_content()` will automatically parse and optimize the embedded images. Use the `config.imagetweak.json` configuration file to disable imageTweak or set the `$option` for imageTweak to `false`: page_content('Sidebar', true, array('image_tweak' => false)); ?> or in a `twig` template: {{ page_content('Sidebar', {'image_tweak':false}) }} **If you are using the TemplateTools, you should not add the imageTweak filter command to your template!** ###`page_description()` Parameter * `boolean $prompt` - optional, default = `true` (`php` only) Usage `php` page_description(); ?> Usage `twig` {{ page_description() }} The function will return the description for the actual [[`PAGE_ID`|Constants#page_id]], see also [[`PAGE_DESCRIPTION`|Constants#page_description]]. `page_description()` automatically detects TOPICS, NEWS and flexContent Articles and will return fitting descriptions. ###`page_footer()` Parameter * `string $date_format` - optional, default = `Y` * `boolean $prompt` - optional, default = `true` (`php` only) Usage `php` page_footer(); ?> Usage `twig` {{ page_footer() }} The function will return the parsed [Website Footer](http://www.websitebaker.org/en/help/user-guide/working-with-wb/settings/general-settings.php), see also [[`PAGE_FOOTER`|Constants#page_footer]]. You can use the placeholders `[YEAR]` and `[PROCESS_TIME]` in the definition for the *Website Footer*: * `[YEAR]` will be replaced with the current date and formatted as specified in `$date_format` * `[PROCESS_TIME]` will be replaced with seconds needed to render the actual page (*not very precise*). ###`page_has_child()` Parameter * `integer $page_id` - optional, default = [`PAGE_ID`](Constants.md#page_id)ยด (ID of the current page) * `boolean $prompt` - optional, default = `true` (`php` only) Usage `php` page_has_child(); ?> This function will return `true` if the given `$page_id` has a child, see also [`PAGE_HAS_CHILD`](Constants.md#page_has_child). ###`page_header()` Parameter * `boolean $prompt` - optional, default = `true` (`php` only) Usage `php` page_header(); ?> Usage `twig` {{ page_header() }} This function will return the [Website Header](http://www.websitebaker.org/en/help/user-guide/working-with-wb/settings/general-settings.php), see also [[`PAGE_HEADER`|Constants#page_header]]. ###`page_image()` Parameter * `integer $page_id` - optional, default `PAGE_ID` * `array $options` - optional, default `array()` Usage `php` page_image(); ?> Usage `twig` {{ page_image() }} This function return the URL of first image of a WYSIWYG section, NEWS, TOPICS or flexContent article or a TOPICS or a flexContent Teaser image. Needed for the Open Graph Support. If no image exists, the function return an empty string. You can place a fallback image `/image/page_image.png` in your template directory, this image will be taken if no other image was detected. The `$options` array can be used to specify the behavior: page_image(PAGE_ID, array( 'fallback_image' => array( 'active' => true, 'url' => TEMPLATE_URL.'/image/page_image.png' ), 'minimum_size' => array( 'width' => 200, 'height' => 150 ) )); ?> By default images must be at minimum 200 pixels width and 150 pixels height. ###`page_keywords()` Parameter * `boolean $prompt` - optional, default = `true` (`php` only) Usage `php` page_keywords(); ?> Usage `twig` {{ page_keywords() }} The function will return the keywords for the actual [[`PAGE_ID`|Constants#page_id]], see also [`PAGE_KEYWORDS`](Constant.mds#page_keywords). `page_keywords()` automatically detects TOPICS, NEWS and flexContent Articles and will return fitting descriptions. ###`page_modified_by()` Parameter * `integer $page_id` - optional, default = [`PAGE_ID`](Constants.md#page_id) * `string $locale` - optional, default = `null` * `boolean $prompt` - optional, default = `true` (`php` only) Usage `php` page_modified_by(); ?> Usage `twig` {{ page_modified_by() }} This function will return the displayname of the user who has last modified the current page. You can also specify a page `ID` and the locale to use. Example `php`: page_modified_by(23); ?> will return displayname of the user who has last modified the page with the `ID` `23`. See also * [`cms_modified_by()`](#cms_modified_by) * [`PAGE_MODIFIED_BY`](Constants.md#page_modified_by) * [`~~ page_modified_by ~~`](kitCommands.md#page_modified_by) * [`page_modified_when()`](#page_modified_when) ###`page_modified_when()` Parameter * `integer $page_id` - optional, default = [`PAGE_ID`](Constants.md#page_id) * `string $format` - optional, default = `'DATETIME_FORMAT'` * `string $locale` - optional, default = `null` * `boolean $prompt` - optional, default = `true` (`php` only) Usage `php` page_modified_when(); ?> Usage `twig` {{ page_modified_when() }} This function will return the date and time the current page has last modified. You can also specify the format of the date and time stamp, a page `ID` and the locale to use. Example `php`: page_modified_when(PAGE_ID, 'Y-m-d'); ?> will return something like `2014-05-16`. The format can be locale string which will be translated, i.e. from /kit2/extension/phpmanufaktur/phpManufaktur/Data/Locale/Metric like the predefined `'DATETIME_FORMAT'` or `'DATE_FORMAT'` or `'TIME_FORMAT'` or it can be any formatting string for the `php` function [`date()`](http://php.net/manual/en/function.date.php). See also * [`cms_modified_when()`](#cms_modified_when) * [`page_modified_by()`](#page_modified_by) * [`PAGE_MODIFIED_WHEN`](Constants.md#page_modified_when) * [`~~ page_modified_when ~~`](kitCommands.md#page_modified_when) ###`page_next_id()` Parameter * `integer $page_id` - optional, default = [`PAGE_ID`](Constants.md#page_id) * `array $visibility` - optional, default = `array('public')` * `boolean $prompt` - optional, default = `true` (`php` only) Usage `php` page_next_id(); ?> Usage `twig` as [Function](http://twig.sensiolabs.org/documentation) {{ page_next_id() }} The function will return by default the ID of the next following page of the current page. Example: {{ page_next_id(34, ['public','hidden']) }} will show next page following to the page ID `34` which is `public` or `hidden`. See also: * [`page_previous_id()`](#page_previous_id) ###`page_option()` Parameter * `string $option` - the option to select * `boolean $prompt` - optional, default = `true` (`php` only) Usage `php` page_option('sample'); ?> Usage `twig` as [Function](http://twig.sensiolabs.org/documentation) {{ page_option('sample') }} Neither WebsiteBaker, LEPTON CMS nor Black CMS offer a possibility to set individual *Options* for a page. But sometimes you need exactly this feature in your template, for example to set a class to indicate a special offer or to show or hide a Sidebar ... If you are using the TemplateTools you can add *Options* to the *Keywords* setting field of the pages: * *Options* must be set as *first* entry in the *Keywords* field * *Options* must be enclosed by `[` square brackets `]` * *Options* must be separated by comma from the *Keywords* * each *Option Pair* must be defined by schema: `key:value` (*Key* followed by a *Colon* and then the *Value*) * multiple *Option Pairs* must be separated by a `|` *Pipe* Example, type in the *Keywords* field: [sample:This is a sample value], Keyword one, Keyword two and save it. This will set the *Option Key* `sample` with the *Option Value* `This is a sample value`. Using `page_keywords()` in your template (`php` example): will output: without the additional *Options* (this is important!). With the function `page_option()` you can access the *Option*: will prompt: This is a sample value You can also define multiple Option Pairs in the *Keywords* field, separate them by a `|`: [color_one:Yellow|color_two:Blue], Keyword one, Keyword two will set the *Option Keys* `color_one` and `color_two`, you can access them (`twig` example):

Option one: {{ page_option('color_one') }} and Option two: {{ page_option('color_two') }}

If a *Option Key* does not exists, the TemplateTools will return `null`, so you can check for `null` in your Template to validate a key (`php` example): page_option('color_one')) { // the option 'color_one' exists, do something $template['cms']->page_option('color_one'); } ?> `twig` example: {% if page_option('color_one') is not null %} {# the option 'color_one' exists, do something #} {{ page_option('color_one') }} {% endif %} ###`page_previous_id()` Parameter * `integer $page_id` - optional, default = [[`PAGE_ID`|Constants#page_id]] * `array $visibility` - optional, default = `array('public')` * `boolean $prompt` - optional, default = `true` (`php` only) Usage `php` page_previous_id(); ?> Usage `twig` as [Function](http://twig.sensiolabs.org/documentation) {{ page_previous_id() }} The function will return by default the ID of the previous page to the current page. Example: page_previous_id(34, array('public', 'hidden'), true); ?> will show previous page for the page ID `34` which is `public` or `hidden`. See also: [`page_next_id()`](#page_next_id) ###`page_sequence()` Parameter * `integer $menu` - optional, default = `1`, * `integer $start_level` - optional, default = `0`, * `array $visibility` - optional, default = `array('public')` Usage `php` only: page_sequence(); ?> This function will return an array with all page ID's in logical sequence through all levels in correct position order. Can be used to build previous / next buttons or to create a Sitemap. The function support up to 10 menu levels at maximum. ###`page_title()` Parameter * `string $spacer` - optional, default = `' - '` * `string $template` - optional, default = `'[PAGE_TITLE]'` * `boolean $prompt` - optional, default = `true` (`php` only) Usage `php` page_title(); ?> Usage `twig` {{ page_title() }} The function will return the formatted page title for the current [[`PAGE_ID`|Constants#page_id]], see also [[`PAGE_TITLE`|Constants#page_title]]. You define your own `$spacer` and `$template`. `page_title()` supports the following placeholders in `$template`: * `[PAGE_TITLE]` - the page title * `[SPACER]` - the defined `$spacer` * `[MENU_TITLE]` - the menu title of the current page * `[WEBSITE_TITLE]` - the [Website Title](http://www.websitebaker.org/en/help/user-guide/working-with-wb/settings/general-settings.php) Assume, the [Website Title](http://www.websitebaker.org/en/help/user-guide/working-with-wb/settings/general-settings.php) is defined as `My fancy website` and the title of the current page is `Bubblegum`, then: page_title(' - ', '[WEBSITE_TITLE][SPACER][PAGE_TITLE]'); ?> or alternate in `twig`: {{ page_title(' - ', '[WEBSITE_TITLE][SPACER][PAGE_TITLE]') }} will prompt: My fancy website - Bubblegum `page_title()` automatically detects TOPICS, NEWS and flexContent Articles and will return fitting descriptions. ###`page_url()` Parameter * `integer $page_id` - optional, default = [[`PAGE_ID`|Constants#page_id]] * `boolean $prompt` - optional, default = `true` (`php` only) Usage `php` page_url(); ?> Usage `twig` {{ page_url() }} The function return by default the URL for the current page by [[`PAGE_ID`|Constants#page_id]]. ###`register_frontend_modfiles()` Parameter * `string $file_type` - optional, default = `css` * `boolean $prompt` - optional, default = `true` (`php` only) Usage `php` register_frontend_modfiles(); ?> Usage `twig` {{ register_frontend_modfiles() }} This function gather `frontend.css` or `frontend.js` files from the `/modules` directory of the CMS to include them in the `` section of the template. register_frontend_modfiles('css'); ?> register_frontend_modfiles('js'); ?> or {{ register_frontend_modfiles('js') }} {{ register_frontend_modfiles('css') }} will create `` tags for the detected `frontend.js` and `frontend.css` files. **The origin function `register_frontend_modfiles()` can also include [jQuery](http://jquery.com/) base files if `$file_type` is `jquery`. It is not recommend to include jQuery in such way - the jQuery inclusion is not actual and may cause a couple of problems, please use the [LibraryAdmin](http://wbaddons.webbird.de/?do=item&item=5) or the jQuery support of the TemplateTools instead! For this reason the support for `jquery` is disabled for the function `register_frontend_modfiles()` inside of the TemplateTools.** ###`register_frontend_modfiles_body()` Parameter * `boolean $prompt` - optional, default = `true` (`php` only) Usage `php` register_frontend_modfiles_body(); ?> Usage `twig` {{ register_frontend_modfiles() }} This function gather `frontend_body.js` files from the `/modules` directory of the CMS to include them before the `` tag of the template. **In different to the origin function `register_frontend_modfiles_body()` this function does not include any jQuery files into the `` section of the template. See also the hint in [`register_frontend_modfiles()`](#register_frontend_modfiles).** ###`show_menu2()` Parameter * `integer|string $aMenu` - optional, default = `0` * `integer $aStart` - optional, default = `SM2_ROOT` * `integer $aMaxLevel` - optional, default = `SM2_CURR+1` * `integer $aOptions` - optional, default = `SM2_TRIM` * `string $aItemOpen` - optional, default = `'[li][a][menu_title]'` * `string $aItemClose` - optional, default = `''` * `string $aMenuOpen` - optional, default = `'[ul]'` * `string $aMenuClose` - optional, default = `''` * `boolean $aTopItemOpen` - optional, default = `false` * `boolean $aTopMenuOpen` - optional, default = `false` * `boolean $prompt` - optional, default = `true` (`php` only) Usage `php` show_menu2(); ?> Usage `twig` {{ show_menu2() }} [`show_menu2()`](http://www.websitebakers.de/sm2/media/README.en.txt) is well documented, [please use the online documentation](http://www.websitebakers.de/sm2/media/README.en.txt) for further information to 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) The TemplateTools add the parameter `$prompt` at the last position, if you set this parameter to `false`, the function will return the result as string: $my_menu = $template['cms']->show_menu2(0, SM2_ROOT, SM2_CURR+1, SM2_TRIM, '[li][a][menu_title]', '', '[ul]', '', false, false, false); See also [[Constants for `show_menu2()`|Constants#show_menu2]] In different to origin usage of the parameter `$aMenu` you can also use the name of the menu definition and not only the integer value. If you `info.php` does contain: $menu[1] = 'Main Navigation'; $menu[2] = 'Footer Navigation'; you can also use: show_menu2('Footer Navigation'); ?> to access the `Footer Navigation` menu. This increase the readability of your templates. ###`wysiwyg_content()` Parameter * `integer $section_id` - the SECTION ID to use * `boolean $prompt` - optional, default = `true` (`php` only) Usage `php` wysiwyg_content(99); ?> Usage `twig` {{ wysiwyg_content(99) }} The function return the content of a WYSIWYG Section. ###`wysiwyg_section_ids()` Parameter * `integer $page_id` - optional, the page ID to use, default = `PAGE_ID` * `integer|string $block_id` - optional, the block to select, default = `1` * `string $order` - optional, the order of the sections, default = `'ASC'` Usage `php` wysiwyg_section_ids(); ?> Usage `twig` {% set section_ids = wysiwyg_section_ids() %} The function return the section ID's for the given page ID and Block ID in the specified order. The block can be an integer or the name of the block. The order can be ascending `'ASC'` (default), descending `'DESC'` or randomized `'RANDOM'`. Example `twig`: {% set section_ids = wysiwyg_section_ids(PAGE_ID_HOME, 'Teaser', 'RANDOM') %} {% if section_ids is not null and section_ids|length > 0 %} {% for section_id in section_ids %}
{{ wysiwyg_content(section_id) }}
{% endfor %} {% endfor %} Will select the WYSIWYG sections `'Teaser'` in randomized order from the Homepage and display them at the current page. ⇐ [[Classic Service]] | [[kitCommand Service]] ⇒