I have created a custom content type 'article' where a custom comment field has been added along with other fields like images, taxonomy terms, etc. In the theme file (page.html.twig) for this content type 'article', I have retrieved a few field values(not all) from the node object using PHP/twig code like node.getCreatedTime/node.field_article_tag, page.content and a view for a related node content. This works fine and the article page is displaying content fields, and page content/related views with comments.

However, when I submit a blank comment the reply page does not contain the node fields along with a view that utilizes node term reference for the related content. This is reasonable since the comment reply page does not belong to a node entity.

My question is how can I access the node ID in the template file for the reply page so that, I can access the fields associated with the submitted article page to theme the page(reply) exactly like the article page(page.html.twig)?



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.