Loading...
Loading...
Drupal Front End Specialist skill for theme development, Twig templates, and rendering system (Drupal 8-11+). Use when working with Drupal themes, Twig syntax, preprocessing, CSS/JS libraries, or template suggestions.
npx skill4agent add omedia/drupal-skill drupal-frontendassets/theme-template/THEMENAMETHEMELABEL.info.yml.libraries.yml.theme.breakpoints.ymltemplates/css/js/references/theming.md{{ variable }}{% if/for/set %}{# comment #}{{ var|filter }}{% extends %}{% block %}{{ 'Text'|t }}{{ attach_library('theme/library') }}{{ url('route.name') }}{{ path('route.name') }}{{ file_url('public://image.jpg') }}{{ content|without('field') }}page.html.twignode.html.twigblock.html.twigfield.html.twigviews-view.html.twigfunction THEMENAME_preprocess_HOOK(&$variables) {
// Add or modify variables
// Access entities, services, configuration
// Prepare data for templates
}hook_preprocess_page()hook_preprocess_node()hook_preprocess_block()hook_preprocess_field()hook_preprocess_html()page--front.html.twig # Homepage
page--node--{nid}.html.twig # Specific node
page--node--{type}.html.twig # Content type
node--{type}--{viewmode}.html.twig # Type + view mode
block--{plugin-id}.html.twig # Specific block
field--{entity}--{field}.html.twig # Specific fieldfunction THEMENAME_theme_suggestions_HOOK_alter(array &$suggestions, array $variables) {
// Add custom suggestions
$suggestions[] = 'custom__suggestion';
}# THEMENAME.libraries.yml
global-styling:
version: 1.0
css:
base:
css/base/reset.css: {}
theme:
css/theme/styles.css: {}
js:
js/custom.js: {}
dependencies:
- core/drupal.info.ymlattach_library()# THEMENAME.breakpoints.yml
THEMENAME.mobile:
label: Mobile
mediaQuery: 'screen and (min-width: 0px)'
weight: 0
THEMENAME.tablet:
label: Tablet
mediaQuery: 'screen and (min-width: 768px)'
weight: 1
THEMENAME.desktop:
label: Desktop
mediaQuery: 'screen and (min-width: 1024px)'
weight: 2cp -r assets/theme-template/ /path/to/drupal/themes/custom/mytheme/
cd /path/to/drupal/themes/custom/mytheme/
# Rename files
mv THEMENAME.info.yml mytheme.info.yml
mv THEMENAME.libraries.yml mytheme.libraries.yml
mv THEMENAME.theme mytheme.thememytheme.info.ymlmytheme.libraries.ymlTHEMENAMETHEMELABELddev drush cr
# Enable via UI at /admin/appearance or:
ddev drush config:set system.theme default mytheme -ysites/default/default.services.ymlsites/default/services.ymltwig.config.debug: truetwig.config.auto_reload: truetwig.config.cache: falseddev drush crtemplates/css/ddev drush cr.themeddev drush cr<!-- FILE NAME SUGGESTIONS:
* page--node--123.html.twig
* page--node--article.html.twig
* page--node.html.twig
x page.html.twig
-->xfunction mytheme_preprocess_page(&$variables) {
// Add site slogan
$variables['site_slogan'] = \Drupal::config('system.site')->get('slogan');
// Add current user
$variables['is_logged_in'] = \Drupal::currentUser()->isAuthenticated();
// Add custom class
$variables['attributes']['class'][] = 'custom-page-class';
}{# templates/page--article.html.twig #}
{% extends "page.html.twig" %}
{% block content %}
<div class="article-wrapper">
{{ parent() }}
</div>
{% endblock %}function mytheme_preprocess_node(&$variables) {
if ($variables['node']->bundle() == 'article') {
$variables['#attached']['library'][] = 'mytheme/article-styles';
}
}{# Get field value #}
{{ node.field_custom.value }}
{# Check if field has value #}
{% if node.field_image|render %}
{{ content.field_image }}
{% endif %}
{# Loop through multi-value field #}
{% for item in node.field_tags %}
{{ item.entity.label }}
{% endfor %}ddev drush cr.libraries.yml{{ dump() }}sites/default/services.ymltwig.config.debug: trueddev drush crreferences/theming.mdassets/theme-template/.info.yml.libraries.yml.theme# Find specific Twig filter
grep -r "clean_class" references/
# Find preprocessing examples
grep -r "preprocess_node" references/
# Find library patterns
grep -r "libraries.yml" references/