This forum is for assistance with theme development.

field_link Add class

So, I know I can do this through preprocess or even creating a field formatter.

Let's say I don't feel like doing all of that because I consider it overhead. I went and use the following

{{ content.field_link[0]|merge({'#options': {'attributes': {'class': ['your-class my-class']}}}) }}

Now, I had the template for field_link overwritten, and I noticed that when I used this option it stopped using my template. Is there a way to add a Class to a field_link in Twig without it breaking your template?

How to show html depending on current language?

i need something like this:

if (language == en)
    <div class="fancy-box-en"></div>
else if (language == fr)
    <div class="fancy-box-tr"></div>
else if ....etc
endif

Acess paragraph's child fields using content

Hello,

I have the following question. I have a paragraph with the following structure:

Paragraph

- field_paragraph_content

  - field_image

It's a paragraph inside a paragraph

From the Parent Twig Paragraph I want to access what would be in the child's Twig the field content.field_image

My requirement is to print the image at the same level of field_paragraph_content but I don't want to manually create the img tag or use drupal_image() or having to manually declare the Image Styles.

Connecting custom content types to the main menu using Twig template

I created a content type with the name 'Brand' and a field that contains three categories which are separate pages on the website. Each of those categories are also shown in the menu. Now I want to create a submenu below each category in the menu where the 'Brand' pages are shown which are connected to the selected category. Is there a way to do this in Twig?

Currently I have the following template where I want to show the items.

Awesome themes i want to develop

Hello

I have just informed that the major newspaper and magazine national websites in Greece are made from Drupal! For example https://www.ethnos.gr/ or https://www.sdna.gr/. 

I have just start learning Drupal while im building websites with wordpress

I want to ask just a question. How can i freely design my regions on a web site in drupal where i would place my blocks like the websites i mentioned above? 

Adding CSS to All pages, including admin

I've created an additional CSS theme for the sub module while the primary front-end dev is working on style.css. Following the excellent docs, particularly all pages, these two CSS files show up on the home page, 404 page. But my ancillary.css does not appear on localhost/taxonomy/term/86/edit where I'm looking for it. 

#mytheme.info.yml

Pages

Subscribe with RSS Subscribe to RSS - Theme development