Timeline for How can I override a displayed node with the content rendered by a custom module?
Current License: CC BY-SA 4.0
7 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jul 29, 2022 at 7:00 | history | edited | avpaderno♦ | CC BY-SA 4.0 |
added a note about using UUID to identify a node, for content exported from a site and imported in all the sites the same code runs
|
Apr 30, 2022 at 20:00 | vote | accept | Anton | ||
Apr 30, 2022 at 17:51 | history | edited | avpaderno♦ | CC BY-SA 4.0 |
made two sentences clearer
|
Apr 30, 2022 at 17:46 | comment | added | avpaderno♦ | You can get the node ID given the path alias, as I show in the updated answer. The code is still hard-coding a value (the path alias), but it's easier to set the same path alias on different sites than getting the same node ID for nodes on different sites. | |
Apr 30, 2022 at 17:40 | history | edited | avpaderno♦ | CC BY-SA 4.0 |
added example code that allows not to hard-code the path alias
|
Apr 30, 2022 at 14:39 | comment | added | Anton | Great idea! I was able to load my custom module content instead here by adding to $build. One question I have for this is: inside hook_ENTITY_TYPE_view(), instead of using the $entity->id(), is there any elegant way to use the custom module's routing.yml to get and call the appropriate controller method dynamically? Otherwise I'm hard-coding ids which feels the same as just creating a 'node--3.html.twig' type of override, and also hard-coding what controller and method to load content from. | |
Apr 30, 2022 at 11:48 | history | answered | avpaderno♦ | CC BY-SA 4.0 |