This forum is for assistance with theme development.

Display author picture on product page

Hi all,

I would like to display the product author's avatar on product page. That is, the user who created the product on marketplace.

I can get username, user ID 
{{ product.uid }} , {{ product_entity.getOwnerId }}

How to get user's picture?

Drupal 10.01, Commerce 2.

Suggestions for breaking node into multiple pages

I find that there seems to be no way to break a long node into multple pages.

There used to be some pagination modules earlier, but Paging and Smart Paging modules never got beyond D7.

I wonder what others are doing to break up pages.

Tbe Book module may be fine when there are chapters, sections, etc.

Incrementing in Twig template

Hi there,

my website menu has multiple levels. On the mobile version, I am working with Accordion elements to expand/collapse them. I want to realize my menu without JS and with CSS only. Therefore, I use checkboxes to trigger the accordion elements to expand/collapse.

For the mobile menu, I created a custom twig template. I added the complete Code below.

Since the checkboxes in my menu are invisible, I work with label elements. Therefore, my checkboxes and the labels have IDs to assign them correctly.

Rendering field values for a custom content type

I've created a simple custom content type with four fields:

  • field_slogan
  • field_poster
  • field_contact
  • body

The field_poster is an image field type. 

I can get the to the other 3 fields to render using:

  • {{ node.field_slogan.0.value|raw }}
  • {{ node.field_contact.0.value|raw }}
  • {{ node.body.value|raw }}

But I can't get the image field - field_poster - to render no matter I try. The following have all failed:

Drupal 9 Multiple controllers with multiple modules and templates

I want to create 2 controllers with 2 templates。 How can I build it wisely? 

I have my first module in drupal 9 with three files in modules section of my drupal:

example1.routing.yml:( in modules/example1/)

exmaple1:
    path: '/example1'
    defaults:
        _controller: '\Drupal\example1\Controller\Example1Controller::view'
    requirements:
        _permission: 'access content'

example1.info.yml: ( in modules/example1/)

name: example1 Template

Pages

Subscribe with RSS Subscribe to RSS - Theme development