Drupal 8 Theming. Exploring Twig & Other Frontend Changes CROWD. Communications Group, LLC CROWD. Communications Group, LLC

Similar documents
Creating a Drupal 8 theme from scratch

Drupal 8. Core and API Changes Shabir Ahmad MS Software Engg. NUST Principal Software Engineser PHP/Drupal

HOW TO CREATE THEME IN MAGENTO 2

Drupal 8 Theming Deep Dive

Cross Site Scripting (XSS) and PHP Security. Anthony Ferrara NYPHP and OWASP Security Series June 30, 2011

Web Development CSE2WD Final Examination June (a) Which organisation is primarily responsible for HTML, CSS and DOM standards?

Making Web Application using Tizen Web UI Framework. Koeun Choi

MAGENTO THEME SHOE STORE

Drupal 8 rocks! (but our CSS & HTML sucks.) Drupal 8 ( CSS HTML )

Web Development 1 A4 Project Description Web Architecture

Designing for Magento

Magento Theme EM0006 for Computer store

Localizing dynamic websites created from open source content management systems

Making Content Editable. Create re-usable templates with total control over the sections you can (and more importantly can't) change.

Drupal CMS for marketing sites

MASTER DRUPAL 7 MODULE DEVELOPMENT

Tutorial: Building a Dojo Application using IBM Rational Application Developer Loan Payment Calculator

Everything you ever wanted to know about Drupal 8*

Beginning Web Development with Node.js

Microsoft Expression Web

Interspire Website Publisher Developer Documentation. Template Customization Guide

Designing for Drupal. John Albin Wilkins

The Django web development framework for the Python-aware

An Introduction to Developing ez Publish Extensions

Certified PHP/MySQL Web Developer Course

A Tour of Silex and Symfony Components. Robert

SMSNotify Extension. User Documentation. Automated SMS sender and customer relationship tool. SMSNotify User Documentation 1

Version 1.0 OFFICIAL THEME USER GUIDE. reva. HTML5 - Responsive One Page Parallax Theme

Magento 1.4 Theming Cookbook

Using Style Sheets for Consistency

DB2 Web Query: Creating Dashboards with HTML Composer and InfoAssist. Jacqueline Jansen Information Builders

DESIGN RESPONSIVELY DRUPAL CAMP CT RESPONSIVE WEB DESIGN AND DRUPAL PROJECT. Monday, August 27, 12

Facebook Twitter YouTube Google Plus Website

Testking.M Q

Configuring the JEvents Component

Dashboard Skin Tutorial. For ETS2 HTML5 Mobile Dashboard v3.0.2

Symfony2: estudo de caso IngressoPrático

Web Programming Step by Step

LEARNING DRUPAL. Instructor : Joshua Owusu-Ansah Company : e4solutions Com. Ltd.

Drupal and ArcGIS Yes, it can be done. Frank McLean Developer

Web Design Basics. Cindy Royal, Ph.D. Associate Professor Texas State University

Shop Manager Manual ConfigBox 3.0 for Magento

Fortis Theme. User Guide. v Magento theme by Infortis. Copyright 2012 Infortis

B1ST a Premium Ticketing System

Modern Web Application Framework Python, SQL Alchemy, Jinja2 & Flask

Data Management Applications with Drupal as Your Framework

The easy way to a nice looking website design. By a total non-designer (Me!)

Selectors in Action LESSON 3

Saturday, June 16, 12. Introducing

Website Planning Checklist

Last week we talked about creating your own tags: div tags and span tags. A div tag goes around other tags, e.g.,:

Magento module Documentation

How to code, test, and validate a web page

About ZPanel. About the framework. The purpose of this guide. Page 1. Author: Bobby Allen Version: 1.1

FormAPI, AJAX and Node.js

Order Manager Toolkit

WEB DEVELOPMENT COURSE (PHP/ MYSQL)

FUNCTIONAL OVERVIEW VERSION: 1.0

Magento Theme Instruction

PROJECT REPORT OF BUILDING COURSE MANAGEMENT SYSTEM BY DJANGO FRAMEWORK

Community Builder Language Package Guide Updated for CB 1.2.3

CREATING HORIZONTAL NAVIGATION BAR USING ADOBE DREAMWEAVER CS5

What about MongoDB? can req.body.input 0; var date = new Date(); do {curdate = new Date();} while(curdate-date<10000)

pset 7: C$50 Finance Zamyla Chan

4 The Product Catalog Module

Intro to Web Programming. using PHP, HTTP, CSS, and Javascript Layton Smith CSE 4000

JOOMLA 2.5 MANUAL WEBSITEDESIGN.CO.ZA

Web Design and Databases WD: Class 7: HTML and CSS Part 3

A CMS framework in Erlang. Marc Worrell WhatWebWhat

Auditing Drupal sites for performance, content and optimal configuration

The purpose of jquery is to make it much easier to use JavaScript on your website.

How To Customize A Forum On Vanilla Forum On A Pcode (Forum) On A Windows (For Forum) On An Html5 (Forums) On Pcode Or Windows 7 (Forforums) On Your Pc

Magento Extension Developer s Guide

ICE: HTML, CSS, and Validation

Web Design and Development ACS Chapter 13. Using Forms 11/30/2015 1

XSS Lightsabre techniques. using Hackvertor

CLASSROOM WEB DESIGNING COURSE

Responsive Web Design Creative License

So we're set? Have your text-editor ready. Be sure you use NotePad, NOT Word or even WordPad. Great, let's get going.

Working with forms in PHP

Using your Drupal Website Book 1 - Drupal Basics

Multilingual content in Drupal 8: a highly evolved permutated API. DrupalCamp Vienna 2013 Francesco Placella

Embedding a Data View dynamic report into an existing web-page

Drupal 8 UNWRAPPED Copyright 2015, ONE Agency België

Drupal for Designers

Creating Online Surveys with Qualtrics Survey Tool

Joostrap Template Documentation

Transcription:

Drupal 8 Theming Exploring Twig & Other Frontend Changes CROWD Communications Group, LLC CROWD Communications Group, LLC

About Me Sean T. Walsh sean@crowdcg.com @seantwalsh @crowdcg irc: crowdcg

Agenda What is Twig & Why is it in D8 Improving the Themer Experience Getting Involved Questions

Twig & D8

A New Template Engine Drupal 7 = PHPTemplate Conflict between Back-end & Front-end Potential Security Issues 55 templates 154 functions Drupal 8 = Twig Keeps Back-end & Frontend Separated More Secure - Autoescaping 149 templates 21 functions

Crash Course

Comments & Vars PHP Twig <?php // My test variable {# My test variable #} {{ variable }} print $variable;

Set Variables {% set variable = 'result' %} {% %} set array = [ 'foo', 'bar', ]

Arrays PHP <?php print $foo[ bar ][ und']->content['baz']['foo']['bar'];?> Twig {{ foo.bar.content.baz.foo.bar }}

Finding Stuff in Twig Print all available variables {{ dump() }} Print content of specific variable {{ dump(foo) }}

Loops <h2>organizers</h2> <ul> {% for user in users %} <li>{{ user.username}}</li> {% endfor %} </ul> <h2>organizers</h2> <ul> <li>david</li> <li>peter</li> <li>sean</li> </ul>

Loops (Cont.) {{ loop.length }} {{ loop.first }} {{ loop.last }} {{ loop.index }} {% if loop.first %}... {% elseif loop.index == 2 %}... {% elseif loop.last %}... {% endif %}

Loop with Empty Text <h2>organizers</h2> <ul> {% for user in users %} <li>{{ user.username}}</li> {% else %} <li>no results found</li> {% endfor %} </ul>

Filter <p> {% filter upper %} uppercase for the win {% endfilter %} </p>

Filter {% set name = 'Sean' %} <span> {{ name length }} </span> <span> 4 </span>

Filters Reference abs batch capitalize convert_encoding date date_modify default escape first format join json_encode keys last length lower merge nl2br number_format raw replace reverse round slice sort split striptags title trim upper url_encode

Twig Blocks page.html.twig {% block headerblock %} <h2>drupalcamp NJ</h2> {% endblock %} page--front.html.twig {% extends "page.html.twig" %} {% block headerblock %} {{ parent() }} <h4>fourth Annual</h4> {% endblock %}

Other Drupal 8 Theme Changes

HTML5 + CSS3

Good Riddance IE6 (<1%) IE7 (<1%) IE8 (~10%)

CSS Built on SMACSS & BEM CSS.field { margin: 20px 15px; }.field.field name { color: orange; } HTML <div class= field field--name >DCNJ</div>

Extra Bits Themes in /themes folder no more /sites/all/themes/ Templates are auto-loaded with hook_theme implementation key! Drupal 8 Theme Layer

theme.info.yml Formerly theme.info (same data) No more stylesheets or scripts properties (still have stylesheets-override & stylesheets-remove) Need to define CSS & JS in *.libraries.yml why-slider: version: 1.x css: theme: css/why-slider.css: {} js: js/why-slider.js: {} dependencies: - core/jquery

Twig FTW! Drupal Specific Functionality

Filters {% set class_name = 'dcnj/2015' %} {% set organizers = [ 'davidhernandez', 'pwolanin', ] %} {{ class_name clean_class }} {{ organizers without('pwolanin') }}, {{ attendees placeholder('you') }} dcnj-2015 davidhernandez you

Other Methods addclass / removeclass <div{{ attributes.addclass('field-item-' ~ name clean_class) }}> <div{{ attributes.removeclass('foo', 'bar').addclass('baz') }}> setattribute / removeattribute <div{{ attributes.setattribute('id', 'camp').setattribute('i-love', 'NJ') }}> <div{{ attributes.removeattribute('id') }}>

Translate {{ 'Author: @username' t({'@username':username}) }} {% trans %} Author {{ username }} {% endtrans %} or

Twig Debug <!-- THEME DEBUG --> <!-- CALL: _theme('page') --> <!-- FILE NAME SUGGESTIONS: * page--front.html.twig * page--node.html.twig x page.html.twig --> <!-- BEGIN OUTPUT from 'core/themes/bartik/templates/page.html.twig' --> Enable in /sites/default/services.yml

Improving the Themer Experience CONSENSUS BANANA Phase 1 Move classes from preprocess to templates Phase 2 Move templates from Core to the new Classy base theme

Consensus Banana

Phase 1 Example node.html.twig {% set classes = [ 'node', 'node--type-' ~ node.bundle clean_class, node.ispromoted()? 'node--promoted', node.issticky()? 'node--sticky', not node.ispublished()? 'node--unpublished', view_mode? 'node--view-mode-' ~ view_mode clean_class, 'clearfix', ] %} <article{{ attributes.addclass(classes) }}> {{ content }} </article>

Phase 2 - Classy

Why Classy

Getting Involved FREE Mentoring & Collaboration Day Sunday, Feb. 1 @ Tigerlabs Monthly Mentoring & Collaboration Third Tuesday 7-9pm @ Tigerlabs IRC #drupal-twig #drupal-contribute Bi-weekly Twig Hangouts (alt. 7am/pm) Next is Thursday, Feb. 12 @ 7pm

Questions? Sean T. Walsh sean@crowdcg.com @seantwalsh @crowdcg CROWD irc: crowdcg Communications Group, LLC CROWD Communications Group, LLC