Skip to content

Instantly share code, notes, and snippets.

@waako
waako / node.twig
Last active May 26, 2016 14:08
Calling ImageStyle throws error when content type has a file field: Cannot use object of type Drupal\node\Entity\Node as array in theme.theme on line 12
<div style="background-image:url('{{ hero_image_url }}');">
This has a background image
</div>
@waako
waako / themename.theme.php
Last active June 17, 2019 12:54
Drupal 8: Get Block's parent Node title and full URL
<?php
use Drupal\Core\Url;
/**
* Implements hook_preprocess_HOOK() for block.html.twig.
*/
function themename_preprocess_block(&$variables) {
// Get Title of Block's parent Node.
$request = \Drupal::request();
@waako
waako / get_paragraph_type_from_field.php
Last active April 27, 2016 15:28 — forked from jenitehan/get_paragraph.php
Get paragraph type of child field item
<?php
/**
* Implements hook_preprocess_HOOK for field--field-structured-content-section.html.twig
*/
function TEMPLATE_preprocess_field__field_structured_content_section(&$variables) {
$items = $variables['items'];
foreach ($items as &$item) {
$paragraph = $item['content']['#paragraph'];
$para_type = $paragraph->getType();
@waako
waako / field.tpl.php
Created July 20, 2015 14:56
add class to the 1st, and every 3rd and 4th element
<?php $max_delta = count($items) - 1; ?>
<div class="<?php print $classes; ?>"<?php print $attributes; ?>>
<?php if (!$label_hidden): ?>
<div class="field-label"<?php print $title_attributes; ?>><?php print $label ?>:&nbsp;</div>
<?php endif; ?>
<div class="field-items content"<?php print $content_attributes; ?>>
<?php foreach ($items as $delta => $item): ?>
<?php
$classes = 'grid-3 ';
$tmp = $delta % 4;
<?php foreach($rows as $row): ?>
<h3><?php print $row['field_collection_name_title']; ?></h3>
<?php if ($row['field_collection_name_subtitle']): ?>
<?php print render($row['field_collection_name_subtitle']['safe_value']); ?>
<?php endif; ?>
<?php print render($row['field_collection_name_content']['safe_value']); ?>
<?php endforeach; ?>

Keybase proof

I hereby claim:

  • I am waako on github.
  • I am waako (https://keybase.io/waako) on keybase.
  • I have a public key whose fingerprint is D262 BF75 7D2A 87EC 8CB3 6971 8471 78CE AF42 256B

To claim this, I am signing this object:

@waako
waako / questions.md
Last active August 29, 2015 14:05
Technical Interview

work environment

  • Equipment provided/used
  • Platform O/S
  • Office layout

Dev

Workflow