How to create ItemList of Objects? #171
Replies: 9 comments
-
Hey, everything you need is there: Lines 116 to 139 in 066463b You can define the |
Beta Was this translation helpful? Give feedback.
-
Thanks. Does it anyway make sense to combine it with Graph or is this any separate declaration?! I also noticed for VideoObject->duration that there is Type "Duration" is required, but for my surprise some types like Duration do not have the expected properties (like here "setDuration"), but have some kind of default-properties which don't make any sense in this Context (like "Image"). What is the idea behind this? How can I set I'm currently doing this: This at least seems to output what is required compared to JSON-LD specs, but gives syntax warning in PhpStorm, as the declaration expects Duration-Typed Object here. |
Beta Was this translation helpful? Give feedback.
-
Regarding the Duration: nothing we can do, schema.org itself doesn't have any more precise info and we also only generate the code from the jsonld standard files (like stated in the README). The Graph is a way to group several top-level types for one page. So for example if you want to describe the |
Beta Was this translation helpful? Give feedback.
-
Thanks for the help. Then the Graph does what I expected to do. Regarding types like Duration, at least for VideoObject duration it has some more specific format here: https://schema.org/Duration I think it's kind of improvement, but Duration should only handle the types that make sense. I don't think "default types" inherited from some kind of default object make any sense here (like image, name, ...). Personally I would make it a class implementing some empty default Type for Types, may be SubType "Duration" and implement some static methods like:
Just as suggestion how I would handle this :-) I also found some other types with inherited "default" attributes that at least for me don't make sense. For example "ItemList" also has bunch of methods/attributes that don't make sense (for the final usage) and should be implemented more near to the specifications to reach more intuitive usage: shows these valid elements/attributes, see https://schema.org/ItemList |
Beta Was this translation helpful? Give feedback.
-
{
"@id": "https://schema.org/Duration",
"@type": "rdfs:Class",
"rdfs:comment": "Quantity: Duration (use <a href=\"http://en.wikipedia.org/wiki/ISO_8601\">ISO 8601 duration format</a>).",
"rdfs:label": "Duration",
"rdfs:subClassOf": {
"@id": "https://schema.org/Quantity"
}
} {
"@id": "https://schema.org/Quantity",
"@type": "rdfs:Class",
"rdfs:comment": "Quantities such as distance, time, mass, weight, etc. Particular instances of say Mass are entities like '3 Kg' or '4 milligrams'.",
"rdfs:label": "Quantity",
"rdfs:subClassOf": {
"@id": "https://schema.org/Intangible"
}
} {
"@id": "https://schema.org/Intangible",
"@type": "rdfs:Class",
"rdfs:comment": "A utility class that serves as the umbrella for a number of 'intangible' things such as quantities, structured values, etc.",
"rdfs:label": "Intangible",
"rdfs:subClassOf": {
"@id": "https://schema.org/Thing"
}
}, {
"@id": "https://schema.org/Thing",
"@type": "rdfs:Class",
"rdfs:comment": "The most generic type of item.",
"rdfs:label": "Thing"
} {
"@id": "https://schema.org/duration",
"@type": "rdf:Property",
"https://schema.org/category": [
"issue-1698",
"issue-1457"
],
"https://schema.org/domainIncludes": [
{
"@id": "https://schema.org/Event"
},
{
"@id": "https://schema.org/Schedule"
},
{
"@id": "https://schema.org/Movie"
},
{
"@id": "https://schema.org/MusicRelease"
},
{
"@id": "https://schema.org/MusicRecording"
},
{
"@id": "https://schema.org/MediaObject"
},
{
"@id": "https://schema.org/Audiobook"
},
{
"@id": "https://schema.org/QuantitativeValueDistribution"
}
],
"https://schema.org/rangeIncludes": {
"@id": "https://schema.org/Duration"
},
"https://schema.org/source": [
{
"@id": "https://github.com/schemaorg/schemaorg/issues/1698"
},
{
"@id": "https://github.com/schemaorg/schemaorg/issues/1457"
}
],
"rdfs:comment": "The duration of the item (movie, audio recording, event, etc.) in <a href=\"http://en.wikipedia.org/wiki/ISO_8601\">ISO 8601 date format</a>.",
"rdfs:label": "duration"
} These are the things we know about the And as schema.org doesn't come with any examples regarding the |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Okay thanks for the feedback. Well then I simply misunderstood, that google doesn't seem to have the actual final specs in its docs. Never the less I think at the end google will "define" the defacto standard as they seem to practive this already as "defacto standard". But I understand your standing. May be I'll end up forking this great library implementing the actual google standards. Lets see. |
Beta Was this translation helpful? Give feedback.
-
Yes, we already had this discussion some times already. Google doesn't 100% follow the official specs. Sometimes they define their own spec. sometimes they use pending properties and so on. And since always we stand our ground to only and always follow the official spec in the way it's provided by schema.org I'm open to an adjustment, like said, to fix the |
Beta Was this translation helpful? Give feedback.
-
@Gummibeer How to set set duration correctly? I am not sure how the DurationContract works. For now I just call:
|
Beta Was this translation helpful? Give feedback.
-
Nice work.
But so far I don't understand how to create an ItemList Object that consists of multiple Object-Types? For example Image or VideoObjects?
Is Graph the correct Collection-Type for that or ItemList?
Graph-Object at least seems to nearly produce what I want using "toScript", but some Google Chrome LD-Test extensions seem not to interpretate it correctly.
Looking into Google-Docs, ItemList should be what I'm searching for?
https://developers.google.com/search/docs/advanced/structured-data/video#item-list
I want to avoid having tons of
<script type="application/ld+json">
in my markup and have a collection with at least all of the same object-type (f.e. Video, People, Images).Is that possible with this library?
Beta Was this translation helpful? Give feedback.
All reactions