0

I am trying to get the value of a field that is displayed in a panel page. I might be going about this all wrong, because I'm still getting used to Drupal 8. I want to display book information, including the ISBN value, which I use to make a link to Amazon.

I first tried a node template: node--book_page.html.twig and was able to do it by inserting the value of {{ content.field_isbn10.0 }} into the URL I added to the twig. This worked great, but when I tried doing the same thing to the template that I set up to be used by the panel page, nothing happens.

I know I have the custom layout twig working as it should, but I'm guessing that there is more to requesting the value than {{ content.field_isbn10.0 }} now that it's going through node_view in Panels.

I have tried adding it to the panel page as entity_field:node:field_isbn10 as well as field_block:node:book_page:field_isbn10. I just can't seem to get how to access the ISBN field value like I did in the node template.

Here's what shows using kint: enter image description here

Here's the top of that knit: enter image description here

11
  • This kint snippet looks like an entity field. So {{ ?.?.?.field_isbn10.value }} should work, if you add the three levels above the field not shown in the screenshot. – 4k4 Oct 22 '18 at 6:30
  • I can't see the field parents on that devel output, but as far I know it is done with {{ content._row.entity.field_isbn10.value }}. That should print out the field value. – user72672 Oct 22 '18 at 8:05
  • I added the top of that knit column. I what was suggested, both with .value and .0 but neither worked. Here is the line I'm using to test it out with in my twig. {% if content.col_2|render|trim is not empty %} <div class="atl__lc lc-2"> {{ content.col_2 }} <p>Amazon: {{ content._row.entity.field_isbn10.0 }}</p></div>{% endif %} – TomP Oct 22 '18 at 14:46
  • Sorry. I can't seem to make code in my comment work – TomP Oct 22 '18 at 14:54
  • Did you try my code – user72672 Oct 22 '18 at 14:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.