This forum is for assistance with theme development.

Looping through specific post type

Hi there, I'm new to drupal since yesterday. I managed to make a custom theme and overwrite some templates by adding new .htm.twig templates for for example a block or a node(post type) I've also created a post type called 'persons'. I was wondering if it is possible to loop through for example all the person posts in a twig template. 

I've already tried looking up specific ways. But none of them fit my situation.

What I basically want to a accomplish is something like this:

```

//pseudo code

{% for person in persons %}

How can I print a specific paragraph type?

In node.html.twig or field.html.twig how can I print a specific type of paragraph (as a bundle, with all its fields)?

Attach custom javascript dynamically generated on a theme page.

In my case I want to write some javascript code inside the paragraph-something.hmtl.twig taking elements from the theme variables and then putting this javascript attached to the bottom of the page. Something like: 

{{ attach_library('my/code') }}

but being able to write the code dynamically and not link to a js file pre-comp.

It's possible?

How to display the thumbnail of a YouTube video in TWIG ?

I created a template for the "Remote video" media type.

I want to display in this template the url of the thumbnail of my video.

I tested this code {{ media.field_thumbnail.value }} but it doesn't work.

The problem is that the thumbnail field is a false field. It does not appear in "Manage fields".

How to display the thumbnail of a YouTube video in TWIG ?

media--remote-video--default.html.twig :

No Way to Select(css) Parent of Active Menu (Superfish)

I need to change the background of the parent li element for a submenu anchor element with the is-active" class.  How do I add a "current" class to the parent li element? (that's one way to do it)

I don't think there's anyway to do it just using css and the existing classes that are available.

Why doesn't the Barrio theme (Bootstrap 5) support drop down menus? That's why I'm using Superfish. Bootstrap 4 supported drop down menus.

themes not working for anonymous users

Hi, I tried installing two different themes (Creative Responsive Theme - https://www.drupal.org/project/creative_responsive_theme and Professional Responsive Theme - https://www.drupal.org/project/professional_responsive_theme). When I apply each of them, they work for me when I'm logged in. However, when I try to access the website while logged out, I get a "The website encountered an unexpected error.

Pages

Subscribe with RSS Subscribe to RSS - Theme development