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().
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | multiple_definitions-3001256-5.patch | 602 bytes | marcelovani |
| #2 | multiple_definitions-3001256-2.patch | 599 bytes | theapi |
Comments
Comment #2
theapi commentedHere's a patch.
Comment #3
theapi commentedComment #4
marcelovaniIt looks like we are passing 4 arguments to sprintf() but only printing 3
Comment #5
marcelovaniI fixed the number or arguments and put the new argument at the end
Comment #6
theapi commentedComment #7
sam152 commentedInteresting, 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?
Comment #9
sam152 commentedNice work, thanks all.
Comment #10
marcelovaniHi, 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
I will add a test for it.
Comment #11
marcelovaniTests here #3007349: Add tests for multiple json ld on the same page