minster.com

By Phil Frilling, 4 January, 2017
A quick php snippet to convert seconds to HH:MM:SS


  $seconds = round($seconds);

  $output = sprintf('%02d:%02d:%02d', ($seconds/ 3600),($seconds/ 60 % 60), $seconds% 60);

Tags

By Phil Frilling, 3 January, 2017
Loading a paragraph field entity for use within node.html.twig. In order to load a field in a paragraph referenced entity, we need to first load the referenced entities

$my_paragraphs = $variables['node']->my_paragraph_field_name->referencedEntities();
Then, we look through the paragraphs to get the correct language, and in turn, pull the field from the paragraph.

    foreach ($my_paragraphs as
By Phil Frilling, 23 September, 2016
I was working on a new Drupal 8 site and had a new geolocation view setup to show locations on a Google map. Everything was working well, then I decided I wanted to add a new field to the node and include that field in the view. After adding the field to the view, I decided against using it and deleted the field from the node (before removing it from the view). This, in turn, deleted the entire view, which cost me a days worth of work!
By Phil Frilling, 30 August, 2016

/**
 * Implements template_preprocess_taxonomy_term().
 */
function THEME_preprocess_taxonomy_term(&$variables) {
  // Add the term name as a variable to use as a class in the twig file.
  $variables['term_name'] = $variables['term']->label();
}

Tags

By Phil Frilling, 30 August, 2016

/**
 * Implements hook_theme_suggestions_alter().
 */
function THEME_theme_suggestions_alter(&$suggestions, $variables, $hook) {
  switch ($hook) {
    case 'taxonomy_term':
      // Add a view mode suggestion for taxonomy terms.
      $suggestions[] 

Tags