Converting Drupal 7 templates (tpl.php) to Drupal 8 twig templates (html.twig)

Hi guys,

I' trying to convert a Drupal 7 template to Drupal 8 twig template and I have converted almost but I stuck on a logic. 

This is the Drupal 7 logic: 

<span class="rk-icon <?php
if ($icon == 'settings'){
    $icon = 'settings-class-icon-large';
}

elseif ($icon == 'affiliates') {
    $icon = 'affiliates-class-icon-large';

}
else {
    $icon = 'icon-class-'. preg_replace('/s$/', '', strtolower($icon)) . '-small';
}
print $icon; ?>"></span>

And I want this in my Drupal 8 twig.

How to display nodes that belong to the same taxonomy term as the current page ?

I created a "Categories" taxonomy vocabulary with the following terms and child terms :

- Crypto
-- Binance
-- Ledger
-- Metamask

- Geek
-- Security
-- Apple

...

The "tags" field allows you to select the categories in the nodes form. A node can have only one category.

Here is my problem

I want to create a Views block on the node pages, which displays other nodes belonging to the same terms and child terms.

Here is an example :

How to change the color of the lines with an svg file and css ?

I customized an SVG file on the website below, to make a background in a block :

https://heropatterns.com/

When I paste the code in my style.css file the code is hundreds of lines long :

Only local images are allowed.

Which is the best Drupal related site?

Drupal.org is nice, esp. for its collection of modules. But I have the feeling drupal.org's forum is not really the place to be for information. And when you look at the level of (in)activity on certain sub-forums of drupal.org/forum (just check the age of the Last Posts), things don't look so encouraging. So: Which Drupal related site is the best / fastest / most comprehensive / most responsive / most active?

Maybe I'm asking this in the wrong place, but where else to go... Flame me if my question is not appropriate for this forum.

Any ideas? Thanks!

How to display a Views block with nodes that share the same taxonomy terms ?

On my Drupal 9 installation, I created a taxonomy vocabulary with terms and subterms.

I want to display under my nodes, a Views block with the other nodes that share the same parent terms.

I found this tutorial :

https://www.hashbangcode.com/article/drupal-9-using-taxonomy-terms-creat...

On my node types I created a field to select the taxonomy term (the category) :

Why I'm getting this error ?

Why I'm getting this error in Drupal 8? 

  • Warning: Invalid argument supplied for foreach() in Drupal\Core\Extension\ThemeHandler->addTheme() (line 125 of core\lib\Drupal\Core\Extension\ThemeHandler.php).

Please give me some hint. 

Pages

Subscribe with RSS Subscribe to RSS - Drupal 8.x