Skip to content
hertsch edited this page May 23, 2014 · 8 revisions

If you are creating Templates in the classic way and not using a CSS Framework like Bootstrap, the Classic Service will spend you some helpful functions to make your work more easy:

###breadcrumb(), classic_breadcrumb()

Parameter

  • array $options - optional, default = array()
  • boolean $prompt - optional, default = true (php only)

Usage php

<?php $template['classic']->breadcrumb(); ?>

Usage twig (as Function)

{{ classic_breadcrumb() }}

Requirements

  • pattern.min.css

This function create a Breadcrumb Navigation for the current page.

You can use the $options array to fit the Breadcrumb to your needs:

{{ bootstrap_breadcrumb({
    'link_home' : true,
    'menu_level': 0,
    'template_directory' : '@pattern/classic/function/breadcrumb/'
}) }}

'link_home' is by default true and will insert a linked 'Home' at the first position of the Breadcrumb.

By default the Breadcrumb will load the needed templates from the 'template_directory' => '@pattern/classic/function/breadcrumb/' - you can define any other Namespace to load the templates from.

###locale_navigation(), classic_locale_navigation()

Parameter

  • array $options - optional, default = array()
  • boolean $prompt - optional, default = true (php only)

Usage php

<?php $template['classic']->locale_navigation(); ?>

Usage twig (as Function)

{{ classic_locale_navigation() }}

Requirements

  • pattern.min.css

This function will create a locale navigation which enable the user to switch between different languages. locale_navigation() will parse the CMS page tree and extract the top level entries to build the locale navigation. The function expect a page structure for multilingual websites as described in the WebsiteBaker documentation.

locale_navigation() expect the language codes in ISO 639-1 and will provide you with the international language name and also with the native language name.

If you have set up your page for German and English languages this will return a navigation with two flags:

which indicate that German is active and English can be selected.

By default the navigation will switch to the first page of the selected locale.

It is more user-friendly to switch from the current page to the fitting page in the selected locale. To realize this, locale_navigation() must know which pages belong together.

You can use the page_option() feature and set the option locale_id with identical values for the fitting pages. For example, you have a page in English language at:

http://domain.tld/page/en/about-us.php

and a page with the same content but in German language at:

http://domain.tld/page/de/ueber-uns.php

Now you can set the option locale_id in keyword field of the page settings of both pages to the value about:

[locale_id:about], Keyword 1, Keyword 2

Repeat this for all fitting pages in all languages. locale_navigation() will use this information to build fitting links in the language selection.

If you are using LEPTON CMS or BlackCat CMS you can also set the URL of the pages, which belong together, to the same name (see: Mehrsprachige Webseiten mit LEPTON CMS), locale_navigation() will detect the fitting pages and create the correct links.

Use the $options array to fit locale_navigation() to your needs, twig example with the default values:

{{ classic_locale_navigation({
    'locales' : null,
    'menu' : 1,
    'visibility' : [
        'public'
    ],
    'template_directory' : '@pattern/classic/function/locale/'
}) }}

With locales you can manually define the languages to use as array ['de','en','fr'], select another menu as the default, change the visibility or the template_directory.

###pager(), classic_pager()

Parameter

  • array $options - optional, default = array()
  • boolean $prompt - optional, default = true (php only)

Usage php

<?php $template['classic']->pager(); ?>

Usage twig (as Function)

{{ classic_pager() }}

Requirements

  • pattern.min.css

This function create a Pager (Previous / Next Pagination) for the current page.

By default the Pager will center the both buttons.

Use the $options array to fit the output of the function to your needs, twig example with the default values:

{{ classic_pager({
    'previous' : true,
    'next' : true,
    'center' : true,
    'visibility' : [
        'public'
    ],
    'template_directory' : '@pattern/classic/function/pager/'
}) }}

Set 'previous' or 'next' to false to hide one of these buttons. If you set 'center' to false the buttons will be aligned to the left and right side of the parent container. By default the 'visibility' is set to 'public' only, you can add other states, i.e. 'hidden'.

By default the function will load the needed twig templates from the @pattern Namespace: 'template_directory' => '@pattern/classic/function/pager/', you also use any other namespace.

###sitelinks_navigation(), classic_sitelinks_navigation()

Parameter

  • integer|string $menu - the menu to use
  • array $options - optional, default = array()
  • boolean $prompt - optional, default = true (php only)

Usage php

<?php $template['classic']->sitelinks_navigation('Teaser'); ?>

Usage twig (as Function)

{{ classic_sitelinks_navigation('Teaser') }}

This function will return a navigation table divided in multiple columns - at minimum 4, at maximum 6, empty columns will be set automatically. The menu tree should be build like this schema:

'Sitelinks' (as Menulink)
  ↳'Column 1' (as Menulink)
    ↳'Link 1' (any content)
    ↳'Link 2' (any content)
  ↳'Column 2' (as Menulink)
    ↳'Link 1' (any content)
    ↳'Link 2' (any content)
...

Use the $options array to fit the output of the function to your needs, twig example with the default values:

{{ bootstrap_sitelinks_navigation('Teaser', {
    'level': 0,
    'strict': true,
    'visibility': [
        'public'
    ],
    'template_directory': '@pattern/classic/function/sitelinks/'
}) }}

Use level to change the menu level. By default strict mode is enabled, the function will only return menu items of type $menu - otherwise also return other menu types.

###social_sharing_buttons()

Parameter

  • array $buttons - the buttons to use
  • array $options - optional, default = array()
  • boolean $prompt - optional, default = true (php only)

Usage php

<?php $template['classic']->social_sharing_buttons(
	array(
    	'email' => array(
    		'to' => '[email protected]',
    		'subject' => 'Any subject'
    		'body' => 'Any email body content',
    		'cc' => '[email protected],second@foobar,tld'
    	),
    	'facebook' => array(
    		'url' => PAGE_URL    		
    	),
    	'tumblr' => array(
    		'url' => PAGE_URL,
    		'title' => PAGE_TITLE
    	),
    	'linkedin' => array(
    		'url' => PAGE_URL,
    		'title' => PAGE_TITLE,
    		'description' => PAGE_DESCRIPTION
    	),
    	'twitter' =>array(
    		'url' => PAGE_URL,
    		'title' => PAGE_TITLE
    	),
    	'reddit' => array(
    		'url' => PAGE_URL
        ),
        'google' =>array(
        	'url' => PAGE_URL
        ),
        'pinterest' => array(
        	'url' => PAGE_URL,
        	'media' => ''
        ),
        'github' => array(
        	'url' => 'https =>//github.com/owner/repository'
        )
    ),
    array(
    	'template_directory' => '@pattern/classic/function/socialsharingbuttons/'
    ),
    true
); ?>

Usage twig

Requirements

  • rrssb.min.css
  • jquery.min.js
  • rrssb.min.js

The example above is showing all available buttons with their individual parameters. Add only the buttons you need. There are only two buttons where the parameters must be set:

  • email - you must set the parameter to and subject all other parameters are optional
  • github - you must set the parameter url which is linking to the desired repository

All other buttons are using default parameters, so you can be lazy and set null or an empty array() as parameter, i.e.:

<?php $template['classic']->social_sharing_buttons(
	array(
    	'facebook' => null,
    	'twitter' => null,
    	'google' => null	        
    )	    
); ?>

will be working fine and showing the buttons for Facebook, Twitter and Google+.

Bootstrap Service | CMS Service