Skip to content

Instantly share code, notes, and snippets.

@hertsch
Last active August 29, 2015 14:01
Show Gist options
  • Save hertsch/86fd4d8a037e7d0e56e4 to your computer and use it in GitHub Desktop.
Save hertsch/86fd4d8a037e7d0e56e4 to your computer and use it in GitHub Desktop.
Code Examples for the TemplateTools used at kit2.phpmanufaktur.de
Code Examples for the TemplateTools used at kit2.phpmanufaktur.de
<div class="body container">
{% set teaser_active = page_option('teaser_active') %}
{% if teaser_active is null %}
{% set teaser_active = true %}
{% endif %}
{% set teaser_order = page_option('teaser_order') %}
{% if teaser_order is null %}
{% set teaser_order = 'ASC' %}
{% endif %}
{% set page_section_ids = wysiwyg_section_ids(PAGE_ID, 'Teaser', teaser_order) %}
{% set home_section_ids = wysiwyg_section_ids(PAGE_ID_HOME, 'Teaser', teaser_order) %}
{% if teaser_active and ((page_section_ids is not null and page_section_ids|length > 0) or
(home_section_ids is not null and home_section_ids|length > 0)) %}
{% if page_section_ids|length > 0 %}
{% set section_ids = page_section_ids %}
{% else %}
{% set section_ids = home_section_ids %}
{% endif %}
<div class="row">
<div class="col-md-9 col-sm-12">
<div class="content">
{{ page_content('Main Content') }}
</div>
</div>
<div class="col-md-3 col-sm-12">
<div class="teaser-container">
<div class="row">
{% for section_id in section_ids %}
{% set teaser = wysiwyg_content(section_id) %}
{% if teaser|length > 0 %}
<div class="col-md-12 col-sm-4 col-xs-6">
<div class="teaser">
{{ teaser }}
</div>
</div>
{% endif %}
{% endfor %}
</div>
</div>
</div>
</div>
{% else %}
{# no teaser present, show only the main content #}
<div class="content">
{{ page_content('Main Content') }}
</div>
{% endif %}
</div>
{% set teaser_active = page_option('teaser_active') %}
{% if teaser_active is null %}
{% set teaser_active = true %}
{% endif %}
{% set teaser_order = page_option('teaser_order') %}
{% if teaser_order is null %}
{% set teaser_order = 'ASC' %}
{% endif %}
{% set page_section_ids = wysiwyg_section_ids(PAGE_ID, 'Teaser', teaser_order) %}
{% set home_section_ids = wysiwyg_section_ids(PAGE_ID_HOME, 'Teaser', teaser_order) %}
{% if teaser_active and ((page_section_ids is not null and page_section_ids|length > 0) or
(home_section_ids is not null and home_section_ids|length > 0)) %}
{# process the teaser ... #}
{% else %}
{# no teaser present, show only the main content #}
<div class="content">
{{ page_content('Main Content') }}
</div>
{% endif %}
{% if page_section_ids|length > 0 %}
{% set section_ids = page_section_ids %}
{% else %}
{% set section_ids = home_section_ids %}
{% endif %}
<div class="row">
<div class="col-md-9 col-sm-12">
<div class="content">
{{ page_content('Main Content') }}
</div>
</div>
<div class="col-md-3 col-sm-12">
<div class="teaser-container">
<div class="row">
{% for section_id in section_ids %}
{% set teaser = wysiwyg_content(section_id) %}
{% if teaser|length > 0 %}
<div class="col-md-12 col-sm-4 col-xs-6">
<div class="teaser">
{{ teaser }}
</div>
</div>
{% endif %}
{% endfor %}
</div>
</div>
</div>
</div>
<?php
if ($template['browser']->name() == BROWSER_CHROME) {
// do something special for the Chrome Browser
?><p>Sie verwenden einen Chrome Browser!</p><?php
}
?>
<?php
if ($template['browser']->is_mobile()) { ?>
<p>Sie verwenden ein mobiles Endgerät!</p>
<?php }
elseif ($template['browser']->is_tablet()) { ?>
<p>Sie verwenden ein Tablet!</p>
<?php }
else { ?>
<p>Sie betrachten diese Seite auf einem Desktop!</p>
<?php }
?>
{% if browser_is_mobile() %}
<p>Sie verwenden ein mobiles Endgerät!</p>
{% elseif browser_is_tablet() %}
<p>Sie verwenden ein Tablet!</p>
{% else %}
<p>Sie betrachten diese Seite auf einem Desktop!</p>
{% endif %}
<p>Sie verwenden den Browser {{ browser_name() }} in der Version {{ browser_version() }} auf der Plattform {{ browser_platform }}</p>
<!DOCTYPE html>
<html lang="en">
<?php
// initialize the TemplateTools
require_once WB_PATH.'/kit2/extension/phpmanufaktur/phpManufaktur/TemplateTools/initialize.php';
// load as simple <head> section
$template['twig']->display('@pattern/bootstrap/head.simple.twig');
?>
<body>
<div class="content-body">
<div class="container">
<?php $template['cms']->page_content(); ?>
</div>
</div>
</body>
</html>
<div class="content-body">
<div class="container">
{% set MAIN_CONTENT = page_content('Main Content') %}
{% set SIDEBAR_LEFT = page_content('Sidebar, Left') %}
{% set SIDEBAR_RIGHT = page_content('Sidebar, Right') %}
{% if SIDEBAR_LEFT|length > 0 %}
<div class="row">
<div class="col-md-4 col-sm-12 sidebar-left">{{ SIDEBAR_LEFT }}</div>
{% if SIDEBAR_RIGHT|length > 0 %}
<div class="col-md-4 col-sm-12 main-content">{{ MAIN_CONTENT }}</div>
<div class="col-md-4 col-sm-12 sidebar-right">{{ SIDEBAR_RIGHT }}</div>
{% else %}
<div class="col-md-8 col-sm-12 main-content">{{ MAIN_CONTENT }}</div>
{% endif %}
</div>
{% elseif SIDEBAR_RIGHT|length > 0 %}
<div class="row">
<div class="col-md-8 col-sm-12 main-content">{{ MAIN_CONTENT }}</div>
<div class="col-md-4 col-sm-12 sidebar-right">{{ SIDEBAR_RIGHT }}</div>
</div>
{% else %}
<div class="main-content">{{ MAIN_CONTENT }}</div>
{% endif %}
</div>
</div>
<body>
<div class="content-body">
<div class="container">
<?php
// get the block contents into variables
$MAIN_CONTENT = $template['cms']->page_content('Main Content', false);
$SIDEBAR_LEFT = $template['cms']->page_content('Sidebar, Left', false);
$SIDEBAR_RIGHT = $template['cms']->page_content('Sidebar, Right', false);
if (!empty($SIDEBAR_LEFT)) {
// the Sidebar LEFT is not empty and must be shown!
?>
<div class="row">
<div class="col-md-4 col-sm-12 sidebar-left"><?php echo $SIDEBAR_LEFT; ?></div>
<?php if (!empty($SIDEBAR_RIGHT)) {
// the Sidebar RIGHT is not empty and must be shown!
?>
<div class="col-md-4 col-sm-12 main-content"><?php echo $MAIN_CONTENT; ?></div>
<div class="col-md-4 col-sm-12 sidebar-right"><?php echo $SIDEBAR_RIGHT; ?></div>
<?php } else { ?>
<div class="col-md-8 col-sm-12 main-content"><?php echo $MAIN_CONTENT; ?></div>
<?php } ?>
</div>
<?php } elseif(!empty($SIDEBAR_RIGHT)) {
// the Sidebar RIGHT is not empty and must be shown!
?>
<div class="row">
<div class="col-md-8 col-sm-12 main-content"><?php echo $MAIN_CONTENT; ?></div>
<div class="col-md-4 col-sm-12 sidebar-right"><?php echo $SIDEBAR_RIGHT; ?></div>
</div>
<?php } else {
// no sidebar is active so we show only the Main Content
?>
<div class="main-content"><?php echo $MAIN_CONTENT; ?></div>
<?php } ?>
</div>
</div>
</body>
$block[1] = 'Main Content';
$block[2] = 'Sidebar, Left';
$block[3] = 'Sidebar, Right';
$block[1] = 'Main Content';
$block[2] = 'Teaser';
<link href="<?php echo LIBRARY_URL; ?>/normalize/latest/normalize.min.css" rel="stylesheet" />
<link href="{{ LIBRARY_URL }}/normalize/latest/normalize.min.css" rel="stylesheet" />
<link href="<?php echo WB_URL; ?>/kit2/extension/phpmanufaktur/phpManufaktur/Library/normalize/latest/normalize.min.css" rel="stylesheet" />
<?php
// Anmeldemaske für den Backendzugang einbinden
if(FRONTEND_LOGIN AND !$wb->is_authenticated() AND VISIBILITY != 'private' ) {
$redirect_url = ((isset($_SESSION['HTTP_REFERER'])
&& $_SESSION['HTTP_REFERER'] != '') ? $_SESSION['HTTP_REFERER'] : WB_URL );
$redirect_url = (isset($thisApp->redirect_url)
? $thisApp->redirect_url : $redirect_url );
?>
<div id="loginmaske">
<form name="login" action="<?php echo LOGIN_URL; ?>" method="post">
<input type="hidden" name="redirect" value="<?php echo $redirect_url;?>" />
<?php
// initialize the TemplateTools
require_once WB_PATH.'/kit2/extension/phpmanufaktur/phpManufaktur/TemplateTools/initialize.php';
if ($template['cms']->cms_maintenance_active()) {
// show the maintenance screen
$template['twig']->display('@pattern/bootstrap/maintenance.twig');
// exit the script
exit();
}
// show the template
$template['twig']->display('twig/template.twig');
<?php
// initialize the TemplateTools
require_once WB_PATH.'/kit2/extension/phpmanufaktur/phpManufaktur/TemplateTools/initialize.php';
if ($template['cms']->cms_maintenance_active()) {
if (false === $template['cms']->cms_maintenance_header_searchbot()) {
// if the site is not crawled by a searchbot show the maintenance screen
$template['twig']->display('@pattern/bootstrap/maintenance.twig');
}
// important: exit the script
exit();
}
// show the template
$template['twig']->display('twig/template.twig');
<body>
{# show a hint if the maintenance mode is active #}
{% include '@pattern/bootstrap/maintenance.hint.twig' %}
<!DOCTYPE html>
<html lang="en">
<?php
require_once WB_PATH.'/kit2/extension/phpmanufaktur/phpManufaktur/TemplateTools/initialize.php';
$template['twig']->display('@pattern/bootstrap/head.simple.twig');
?>
<body>
<div class="container">
<div class="logo-container row">
<div class="logo col-sm-3 hidden-xs">
<a href="<?php echo CMS_URL; ?>" title="<?php echo CMS_TITLE; ?>">
<img src="<?php echo MANUFAKTUR_URL; ?>/TemplateTools/extension.jpg" class="img-responsive" alt="TemplateTools" />
</a>
</div>
<div class="template-name col-sm-9 col-xs-12">
<div class="template-name-header">
<?php echo TEMPLATE_NAME; ?>
</div>
<div class="template-name-path">
<?php echo TEMPLATE_PATH; ?>
</div>
</div>
</div>
<div class="content row">
<div class="main col-sm-9 col-sm-push-3">
<?php $template['twig']->display('@pattern/bootstrap/search.div.twig'); ?>
<?php $template['bootstrap']->breadcrumb(); ?>
<?php $template['cms']->page_content(); ?>
</div>
<div class="navigation col-sm-3 col-sm-pull-9">
<?php $template['cms']->show_menu2(); ?>
</div>
</div>
<div class="footer row">
<div class="col-sm-9 col-sm-offset-3">
<?php echo PAGE_FOOTER; ?>
</div>
</div>
</div>
</body>
</html>
<a href="<?php echo CMS_URL; ?>" title="<?php echo CMS_TITLE; ?>">
{% extends "@pattern/bootstrap/html.simple.twig" %}
{% block body %}
<div class="container">
<div class="logo-container row">
<div class="logo col-sm-3 hidden-xs">
<a href="{{ CMS_URL }}" title="{{ CMS_TITLE }}">
<img src="{{ MANUFAKTUR_URL }}/TemplateTools/extension.jpg" class="img-responsive" alt="TemplateTools" />
</a>
</div>
<div class="template-name col-sm-9 col-xs-12">
<div class="template-name-header">
{{ TEMPLATE_NAME }}
</div>
<div class="template-name-path">
{{ TEMPLATE_PATH }}
</div>
</div>
</div>
<div class="content row">
<div class="main col-sm-9 col-sm-push-3">
{% include('@pattern/bootstrap/search.div.twig') %}
{{ bootstrap_breadcrumb() }}
{{ page_content() }}
</div>
<div class="navigation col-sm-3 col-sm-pull-9">
{{ show_menu2() }}
</div>
</div>
<div class="footer row">
<div class="col-sm-9 col-sm-offset-3">
{{ PAGE_FOOTER }}
</div>
</div>
</div>
{% endblock body %}
<a href="{{ CMS_URL }}" title="{{ CMS_TITLE }}">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment