Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi
I would like to be able to get a node as a shortcode with view mode option
exemple:
I would to display the node 1 with the teaser view mode inside another node
[node nid=1 view=teaser]
Is it possible to do that ?
Comments
Comment #1
Denes.Szabo CreditAttribution: Denes.Szabo commentedHi, yes this feature can be doable. But, you have to consider, the nodes with input filters are cacheable. So, the embedded node content will not refresh automatically when you alter the related (nid=1 in your example) content only just after a cache clear (cache_filter).
So, I would recommend you another solution, maybe entity_reference to the related, embedded content.
Comment #2
creatile CreditAttribution: creatile commentedThank you for your answer
I have already tried entity_reference but I can't change the order of nodes to display
I found the solution with node_embed project
Best regards
Comment #3
Denes.Szabo CreditAttribution: Denes.Szabo commentedI checked the node_embed module a little bit: I will implement the embed shortcode based on this module.
Comment #4
creatile CreditAttribution: creatile commentedThat's a good news
The idea is to create content types for :
- pdf
- video
- external link
and to make different view modes for all of them
so it will be possible to embed these nodes easily
Comment #5
Peter Törnstrand CreditAttribution: Peter Törnstrand commentedWhile you're at this I would love to see this feature extended to views and blocks. It would also be cool if you could specify the display mode to use for embedding.
For example:
[embed:node/1:teaser]
[embed:block/delta]
[embed:view/name:display_name]
For views you could even supply arguments:
[embed:view/name:display_name,arg1,arg2,arg3]
Comment #6
Denes.Szabo CreditAttribution: Denes.Szabo commentedThe embed_content macro currently works for nodes but not with full view mode…
I need to develop embed entity macro for embedding other type content.
Comment #7
gmclelland CreditAttribution: gmclelland commentedFYI.. there's also https://drupal.org/project/token_insert. See it in action at https://drupal.psu.edu/content/token-insert-entity-field-formatters-and-...
Edit: Forgot to mention https://drupal.org/project/token_insert_entity
Comment #8
Denes.Szabo CreditAttribution: Denes.Szabo commented