Score:1

How can I get the canonical path with {{ path('entity.node.canonical') }}

us flag

When I use {{ path('entity.node.canonical', {'node': node.id}) }} in a node template file, it renders the path alias.

How can I get the canonical path?

Score:3
us flag

{{ path('entity.node.canonical', {'node': node.id}, {'path_processing': false}) }}

Score:-2
bt flag

{# /**

  • @file
  • Theme override to display a view of unformatted rows.
  • Available variables:
    • title: The title of this group of rows. May be empty.
    • rows: A list of the view's row items.
    • attributes: The row's HTML attributes.
    • content: The row's content.
    • view: The view object.
    • default_row_class: A flag indicating whether default classes should be
  • used on rows.
  • @see template_preprocess_views_view_unformatted() */ #} {% if title %}

{{ title }}

{% endif %}

{% for row in rows %} {% set row_classes = [ default_row_class ? 'views-row', ] %} {% endfor %}

<div{{ row.attributes.addClass(row_classes) }}>

                <div> SHOOP</div>

{# The content type is named :"shop" If we have just added one node for in contente type "SHOOP", we can keep the node content type id with : {{ view.result.0.nid) }}. Il we have more node content type, we have to use the loop "for". And in order to reach each field value we use this followig method. Note thate, the active template was : "views-wiew--unuformated.htlm.twig". The suggested view that we create in the theme suggestion we be : "views-view--shop.html.twig"

#}

{% set items = view.result %} 

{#for each item 'of content type' #} 
{% for item in items %}
        
        {# Champ 'Title' of content type "SHOP"  #}
        {{ item._entity.title.value|raw}}

        {# Champ 'Image 1' du TDC "SHOP"  #}
         <img src="{{ file_url(item._entity.field_image_1.entity.uri.value) }}"/>

         {# Champ 'Image 2' of content type "SHOP"  #}
        <img src="{{ file_url(item._entity.field_image_2.entity.uri.value) }}"/>

        <img src="{{ file_url(item._entity.field_image_3.entity.uri.value) }}"/>

        {# field 'Description' of content type "SHOP"  #}
        {{ item._entity.field_description.value|raw }}

        {# Champ 'weight' of content type "SHOP" #}
        {{ item._entity.field_weight.value }}

<button type="button" class="btn btn-primary">
     <a href="{{ path('entity.node.canonical', {'node' : item.nid }) }}"> {{"See more"|t}}
    </a>  
</button> 
{% endfor %} 
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.