Skip to content

Instantly share code, notes, and snippets.

View thamas's full-sized avatar

Tamás Hajas thamas

View GitHub Profile
@thamas
thamas / menu.html.twig
Last active October 3, 2018 14:16
Full template
{#
/**
* @file
* Theme override to display a menu.
*/
#}
{% import _self as menus %}
{#
We call a macro which calls itself to render the full tree.
@thamas
thamas / search-icon.twig
Created January 10, 2018 08:00
Include svg icon in Drupal 8 Twig and link it to the search results page
<div class="search__iconwrap">
<a class="search__link" title="{{ 'Go to the search page'|t }}" href="{{ path('search.view') }}">
{% include active_theme_path() ~ '/images/svg/search.svg' %}
</a>
</div>
@thamas
thamas / googlepizza.txt
Last active October 5, 2017 08:32
Telefonos pizzarendelés a Google-től :)
- Halló! Sarki Pizza?
- Nem Uram, ez Google Pizza!
- Óh, bocsánat, akkor rossz számot hívtam...
- Nem Uram, jó számot hívott! Csak a Google megvásárolta az üzletet.
- Oké. Akkor szeretnék rendelni...
{% if node.created.value and node.changed.value is defined %}
{% set node_pub = node.created.value|format_date() %}
{% set node_upd = node.changed.value|format_date() %}
<p>
{% trans %}
Published: {{ node_pub|placeholder|striptags }},
last updated: {{ node_upd|placeholder|striptags }}
{% endtrans %}
</p>
{% endif %}
{% set current_date = date()|date('U')|format_date('short') %}
<p>
{% trans %}
The current date is {{ current_date|placeholder|striptags }}
{% endtrans %}
</p>

Working with chx was like having the lead engineer of the best formula-1 team tune your car! I do not think anyone knows Drupal 8 migration better (because he wrote the code). He is a professional developer and a kind person in one.

@thamas
thamas / stephen-hay-backside-of-the-css-class.md
Last active May 13, 2016 09:54
Digest of the presentation The Back(side) of the Class by Stephen Hay

Stephen Hay: The Back(side) of the Class

Video: https://vimeo.com/134190982

Have you ever been taught that “modularizing” CSS via an endless number of “reusable” object-like “classes” is the “proper” way to use CSS on “large-scale websites”, or have you taught others that these are “best practices”? Do you think there’s a difference between the term “large-scale websites” and “enterprise websites”? When I say “inheritance” and “specificity”, do you feel dirty?
If you answered yes to the above questions, then you, my friend, are going to absolutely hate this session.
Slides: http://slideshare.net/stephenhay/the-backsideoftheclass
About Stephen: http://the-haystack.com
More about CSS Day: http://cssday.nl or https://twitter.com/cssdayconf

@thamas
thamas / menu.html.twig
Last active May 3, 2016 09:54
addClass
{{ menus.menu_links(items, attributes, 0, menu_name) }}
{% macro menu_links(items, attributes, menu_level, menu_name) %}
{% import _self as menus %}
{%
set menu_classes = [
'c-menu-' ~ menu_name|clean_class,
]
%}
{% if items %}
@thamas
thamas / menu.html.twig
Last active May 3, 2016 09:53
addClass to sub ul
{{ menus.menu_links(items, attributes, 0, menu_name) }}
{% macro menu_links(items, attributes, menu_level, menu_name) %}
{% import _self as menus %}
{%
set menu_classes = [
'o-menu',
'c-menu-' ~ menu_name|clean_class,
]
%}