Open yorkshire-pudding opened 5 months ago
@laryn - I've added a PR that mirrors the way node.tpl.php
does it
This looks good to me. This can be useful for things like adding links to hashes.
@yorkshire-pudding @herbdool What are your thoughts on whether we should preprocess and use backdrop_html_id for this?
Probably the core node implementation should do that too -- there are certainly cases I could see where a paragraph or node could be displayed more than once on a page, perhaps with different view modes, in a block, etc., and the current implementation would result in multiple identical id
values.
@laryn
I did think about using preprocess
to prepare the variable and therefore make the template file have a much simpler change, but erred on the side of copying core.
I hadn't thought about the possibility of displaying the same paragraph twice, but that does strengthen the case for using preprocess
, and using the function you suggest.
Does the "apenty" module fulfill this need, it has the "heading" type where you can create an anchor.
Does the "apenty" module fulfill this need, it has the "heading" type where you can create an anchor.
There is a need for this in paragraphs without installing additional modules
@laryn - I have updated this PR to use backdrop_html_id()
within the preprocess
function.
Tested by embedding the node again on the page in a block.
First one is id="paragraphs-item-1"
and second is id="paragraphs-item-1--2"
Nodes have an id that relates to the node id (
nid
)It would be good, for the purposes of being able to navigate to a paragraph via an anchor link, to have the same in the template for
paragraphs_item
. For example.Where
37
is theitem_id
of the paragraphs item.I tried to do this in a
paragraphs-item.tpl.php
file in my theme, and it worked, but I couldn't then do any other paragraphs-item templates to override more specific paragraph types.