On Github pakmanlh / DdayBilbao2014
Vegan Themer at @pakmanlh in the internets
#DdayBilbao2014
<div class="foo bar baz whatever"> <div class="foo bar baz whatever"> <div class="foo bar baz whatever"> <h1 class="pane-title">hello im drupal</h1> <div class="node node-type node-viewmode-argh"> always add another div </div> </div> </div> </div>
<style media="all">
@import url("sites/modules/system/system.base.css?mz4mz0");
@import url("sites/modules/system/system.menus.css?mz4mz0");
@import url("sites/modules/system/system.messages.css?mz4mz0");
@import url("sites/modules/system/system.theme.css?mz4mz0");</style>
<style media="all">
@import url("sites/modules/contextual/contextual.css?mz4mz0");
</style>
<style media="all">
@import url("sites/modules/aggregator/aggregator.css?mz4mz0");
@import url("sites/modules/book/book.css?mz4mz0");
@import url("sites/modules/comment/comment.css?mz4mz0");
@import url("sites/sites/all/modules/contrib/date/date_api/date.css?mz4mz0");
@import url("sites/modules/field/theme/field.css?mz4mz0");
@import url("sites/modules/node/node.css?mz4mz0");
@import url("sites/sites/all/modules/contrib/picture/picture_wysiwyg.css?mz4mz0");
@import url("sites/modules/poll/poll.css?mz4mz0");
@import url("sites/modules/search/search.css?mz4mz0");
@import url("sites/sites/all/modules/contrib/search_krumo/search_krumo.css?mz4mz0");
@import url("sites/modules/user/user.css?mz4mz0");
@import url("sites/sites/all/modules/contrib/video_filter/video_filter.css?mz4mz0");
@import url("sites/modules/forum/forum.css?mz4mz0");
@import url("sites/sites/all/modules/contrib/views/css/views.css?mz4mz0");
@import url("sites/sites/all/modules/contrib/admin_menu/admin_menu.css?mz4mz0");
@import url("sites/sites/all/modules/contrib/admin_menu/admin_menu.uid1.css?mz4mz0");
</style>
<style media="all">
@import url("sites/sites/all/modules/contrib/ctools/css/ctools.css?mz4mz0");
@import url("sites/sites/all/modules/contrib/panels/css/panels.css?mz4mz0");
@import url("sites/sites/all/modules/contrib/panels/plugins/layouts/twocol_stacked/twocol_stacked.css?mz4mz0");
@import url("sites/sites/all/themes/mothership/mothership/templates/panels//mothership-html5page/mothership-html5page.admin.css?mz4mz0");
</style>
<style media="all">
@import url("sites/themes/stark/layout.css?mz4mz0");
</style>
<div class="field field-something field-even_more another-field-cause-im-drupal"> wait im just a piece of data </div>
<header role="banner"> <nav> <a href="/">home</a> | <a href="/info">info</a> </nav> </header> <main> <div> ... </div> </main> <footer role=""> </footer>
75% menos de ID's *
<body class="html one-sidebar sidebar-first not-front logged-in page-node page-node- page-node-4 node-type-fieldtest ">
<body class=" how-about-we_figure_that-out ">
// .block__element--modifier
.notification {
/* general styles for all notifications */
}
.notification--info {
/* blue color adjustments */
}
proveer visibilidad
themes ahora viven en "/themes"
o "sites/ *** /themes"
modulename/templates/*.html.twig
$settings['twig_debug'] = TRUE;settings.php
Las plantillas twig son interpretables (Back y Front)
(no todavía pero con previsión)
ahora es un bloque exportable
facilísimo
/* comment */ <?php print $foo ; ?>phptemplate
{# comment #}
{{ foo }}
twig
/* so php template Now where is that value again */ <?php print $foo['bar']['UND']->baz['what']->thefuck['seriously'] ?>phptemplate
{# hello twig can you find valdo ? #}
{{ foo.bar.baz.done.with.this.shit }}
{{ foo['bar'] }}
{% functions %}
Twig
<?php if($foo): ?> <?php print $var; ?> <?php endif; ?>phptemplate
{% if foo %}
{{ var }}
{% endif %}
twig
<h2>Team Awesome </h2>
<ul>
{% for user in users %}
<li>{{ user.username}}</li>
{% endfor %}
</ul>
twig
<h2>Team Awesome </h2> <ul> <li>cottset</li> <li>joel</li> <li>jen</li> <li>mark carver</li> <li>mortendk</li> </ul>drupal8
{{ loop.length }}
{{ loop.first }}
{{ loop.last }}
{{ loop.index }}
{% if loop.first %}
...
{% elseif loop.index == 2 %}
...
{% elseif loop.last %}
...
{% endif %}
{% set foo %}
count-{{ loop.index }}
{% endset %}
{{ foo }},
twig
count-1,count-2, count-3,output
<p>
{% filter upper %}
uppercase for the win
{% endfilter %}
</p>
<p> UPPERCASE FOR THE WIN </p>
{{ foo|dostufftofoo }}
{# name = <a hred="foo">pako</a> #}
{{ name|striptags|title }}
twig
Pako
name = name description = This is my epic D7 theme screenshot = screenshot.png engine = phptemplate core = 7.x php = 5.2 regions[header] = Header regions[logo] = Logo regions[menu] = Menu regions[messages] = Messages regions[content] = Content regions[footer] = Footer stylesheets[all][] = css/style.css #FOAD fix stylesheets[all][] = donteverloadmeagain.css
name: drupal8themename type: theme description: This is my epic D8 theme package: Core core: 8.x stylesheets: all: - css/layout.css print: - css/print.css stylesheets-remove: - system.theme.css - user.icons.css - stuffidontwant.css regions: header: Header logo: Logo menu: Menu messages: Messages content: Content footer: Footer # engine: phptemplate
# engine: phptemplatethemename.info
stylesheets[all][] = css/style.css #FOAD fix ;stylesheets[all][] = donteverloadmeagain.css stylesheets[all][] = system.theme.css stylesheets[all][] = user.icons.css stylesheets[all][] = stuffidontwant.cssdrupal 7
stylesheets-remove: - system.theme.css - user.icons.css - stuffidontwant.cssdrupal 8
<?php if ($page['footer']): ?> <footer role="contentinfo"> <?php print render($page[footer]); ?> </footer> <?php endid ?><?php print render($page[region]); ?>
{% if page.footer %}
<footer role="contentinfo">
{{ page.footer}}
</footer>
{% endif %}
twig: {{ page.region }}
<div{{ attributes }}>
{{ title_prefix }}
{% if label %}
<h2{{ title_attributes }}>{{ label }}</h2>
{% endif %}
{{ title_suffix }}
<div{{ content_attributes }}>
{{ content }}
</div>
</div>
block.twig
<nav class="{{ attributes.class }}" role="{{ attributes.role}}">
{{ title_prefix }}
{% if label %}
<h2{{ title_attributes }}>{{ label }}</h2>
{% endif %}
{{ title_suffix }}
{{ content }}
</nav>
block--system-menu-block.html.twig
theme hook suggestions
<div class="block blockmore blockmorecauseofdrupal">...</div>
{{ attributes.class |replace( {'block': '' }) }}
block.html.
<nav class="{{ attributes.class }}" role="{{ attributes.role}}">
{{ title_prefix }}
{% if label %}
<h2{{ title_attributes }}>{{ label }}</h2>
{% endif %}
{{ title_suffix }}
{{ content }}
</nav>
block--system-menu-block.html.twig
<nav class="l-foobar mainmenu" role="navigation"> ... content ... </nav>Done
<article {{attributes}}=""> ... </article>
<article class="{{attributes.class}}" {{attributes}}="">
...
</article>
<article class="{{ attributes.class }}" role="{{ attributes.role }}" {{attributes}}="">
....
</article>
<article class="foo {{ attributes.class}}" {{attributes}}="">
foo
</article>
.twig
<article class="foo field-foo" role="something"> foo </article>drupal
<div class="tags"> <span>3 tags:</span> <a href="#" class="odd">foo</a>, <a href="#" class="even resaltado">bar</a>, <a href="#" class="odd">baz</a>. </div>CSS
.resaltado{
color: green;
font-style:italic;
}
<article class="...">
....
{{ content.field_tags}}
{{ content|without('field_tags') }}
</article>
node.html.twig
{# Start the loop #}
{% for delta, item in items %}
{# create a class var #}
{% set class %}
{# odd even #}
{{- cycle(["even", "odd"], delta) }}
{# count-x #}
count-{{ loop.index -}}"
{% endset %}
<a href="#" class="{{class}}">{{item}}</a>,
{# end the loop #}
{% endfor %}
field--field-tags.html.twig
<a href="#" class="odd count-1">Iturraspe</a>, <a href="#" class="even count-2">Goikoetxea</a>, <a href="#" class="odd count-3">Aldaiturriaga</a>,drupal8
{# first loop #}
{% if loop.first %}
{# set tags / tag #}
<span>
{% if loop.length > 1 %}
{{ loop.length }}
tags:
{% else %}
tag:
{% endif %}
<span>
...
</span></span>
field--field-tags.html.twig
<span>3 tags:</span>
{% if loop.first %}
...
{% elseif loop.index == 2 %}
<a href="#" class="resaltado {{class}}">{{item}}</a>,
...
{# end the loop #}
{% endfor %}
field--field-tags.html.twig
<a href="#" class="odd count-1">Iturraspe</a> <a href="#" class="resaltado even count-2">Goikoetxea</a> <a href="#" class="odd count-3">Aldaiturriaga</a>
{% if loop.first %}
<span>
{% if loop.length > 1 %}
{{ loop.length }} tags:
{% else %}
tag:
{% endif %}
<span>
<a href="#" class="{{class}}">{{item}}</a>,
{% elseif loop.index == 2 %}
<a href="#" class="resaltado {{class}}">{{item}}</a>,
{% elseif loop.last %}
<a href="#" class="{{class}}">{{item}}</a>.
{% else %}
<a href="#" class="{{class}}">{{item}}</a>,
{% endif %}
</span></span>
field--field-tags.html.twig
3 tags: <a href="#" class="odd count-1">Iturraspe</a>, <a href="#" class="resaltado even count-2">Goikoetxea</a>, <a href="#" class="odd count-3">Aldaiturriaga</a>.
{% block foobar %}
{# puedo ser otra cosa #}
{% endblock %}
{% block headerblock %}
Change me if Im on the frontpage
{% endblock %}
page.twig.html
{% extends "themes/drupal8theme/templates/page.html.twig" %}
{% block headerblock %}
Im on the frontpage :)
{% endblock %}
page--front.html.twig
<a href="{{ url('<front>') }}" title="{{ 'Home'|t }}" rel="home" class="site-logo"></a>
{{ 'last checked: @time ago'| t({'@time':time}) }}
{% trans %}
Hi im a euskaldun and i speak funny: ongi etorri
{% endtrans %}
{% trans %}
Kaixo euskaldun.
{% plural count %}
Kaixo {{ count }} euskaldunes.
{% endtrans %}
name: Awesome Theme description: 'An awesome D8 theme.' base theme: classy package: Custom type: theme version: 1.0 core: 8.x
pako.garcia@ymbra.comVegan Themer at @pakmanlh in the internets
#DdayBilbao2014
many thanks to mortendk for the inspiration