Although multiple entity definitions can be created, only one makes it to the page.
This is due to the attached html_head id being the same for all the entity definitions in json_ld_schema_entity_view().

Comments

theapi created an issue. See original summary.

theapi’s picture

StatusFileSize
new599 bytes

Here's a patch.

theapi’s picture

Assigned: theapi » Unassigned
marcelovani’s picture

Status: Active » Needs work

It looks like we are passing 4 arguments to sprintf() but only printing 3

marcelovani’s picture

Status: Needs work » Needs review
StatusFileSize
new602 bytes

I fixed the number or arguments and put the new argument at the end

theapi’s picture

Status: Needs review » Reviewed & tested by the community
sam152’s picture

Interesting, so we had multiple definitions for a single entity on the same page. Nice fix. Wondering how hard it would be to add a test for this as well?

  • Sam152 committed 5c15553 on 8.x-1.x authored by marcelovani
    Issue #3001256 by theapi, marcelovani: Allow multiple entity definitions...
sam152’s picture

Status: Reviewed & tested by the community » Fixed

Nice work, thanks all.

marcelovani’s picture

Hi, thanks for the swift response.

This is an example of the fix, say we want to display the json_ld for breadcrumbs when viewing the article

Without the patch
<script type="application/ld+json">{"@context":"http:\/\/schema.org","@type":"Brewery","name":"Nissan Leaf Hatchback Review","aggregateRating":[{"@type":"AggregateRating","ratingValue":1}],"publisher":{"@type":"Organization","name":"Example Corp","logo":{"@type":"ImageObject","url":"http:\/\/www.example.com\/logo.jpg"}}}</script>

After the patch

<script type="application/ld+json">{"@context":"http:\/\/schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":{"@type":"Thing","@id":"\/"}}]}</script>
<script type="application/ld+json">{"@context":"http:\/\/schema.org","@type":"Brewery","name":"Nissan Leaf Hatchback Review","aggregateRating":[{"@type":"AggregateRating","ratingValue":1}],"publisher":{"@type":"Organization","name":"Example Corp","logo":{"@type":"ImageObject","url":"http:\/\/www.example.com\/logo.jpg"}}}</script>

I will add a test for it.

marcelovani’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.