This forum is for assistance with theme development.

Drupal 8 theming a view advice

Hi,
I'm very new to Drupal and I’m experimenting theming in Drupal 8. I want to have a certain view on the frontpage as a block. The block has some kind of table with an image and a clickable title of a certain contenttype. Creating this is not really difficult, I already created this, but I want something like this:

The first row:
title | image | title | image | title | image

but now the second row should be
image | title | image | title | image | title

in total that gives:

$variables is cached...

In relation to this, now resolved, issue (thanks again Jeff!):

https://www.drupal.org/node/2679086

Ok, so in MY_THEME.theme I have:

function MY_THEME_preprocess_menu(&$variables) {
  $variables['MY_THEME_path'] = \Drupal::request()->getPathInfo();
}

so that in my menus I can see what page I'm on and style the links accordingly.

Dropdown Main menu

Sorry, but English is not my native language.
Therefore, some descriptions of functions cause me some confusion. Especially if they are "scattered" in different parts of the documentation, forums, questions ... And provide partial answers.
Although ... Maybe it's just a "problem" of translation?

Resolved: Taxonomy image with language specific link

Scenario

On a multilingual site, I need to show a list of vocabulary terms, not in text but all terms replaced by their respective image links.

What's the URI of the page I'm on?

I'm sure there's a very simple answer to this, but I need to determine the URL, URI, whatever, of the page that this template is currently executing on.

When I try to see what's in the Twig global variable "app" I get NULL. When I try to see what's in the variable "parent" I get NULL.

Thank you.

Attach javascript file to a specific block

Hello all,

I tried in mytheme.theme

function mytheme_preprocess_block(&$variables) {
  if ($variables['elements']['#id'] == 'myblock') {
    $variables['#attached']['library'][] = 'js/readmore.min.js';
  }
}

I get:
User warning: The following theme is missing from the file system: js in drupal_get_filename() ...core/includes/bootstrap.inc

readmore.min.js is present in themes/mytheme/js/

Pages

Subscribe with RSS Subscribe to RSS - Theme development