Decide which types get their own node and which ones get incorporated

Created on 16 August 2023, over 1 year ago
Updated 24 October 2023, about 1 year ago

Problem/Motivation

Let's say my company wants to include a service on our website.
We would create a service Schema.org type.
To advertise the prices we do for different types of customers, to follow the Schema.org convention
we would use the offers property and use the Offer type to define
the different prices for the different target audiences.

The thing is, although I can see where to set types that get defined directly in the parent node's form,
this approach creates new Drupal nodes for each offer, which is unnecessary because the offers are not
relevant on their own, but rather when incorporated in the service's JSON-LD and page.

My question is... is there a way to define which Schema.org field types get their own nodes and which ones
just get incorporated into their parent's node's JSON-LD.

Apologies if there's already a way to do this, but I can't seem to be able to find it.

Steps to reproduce

Edit the "Inline form entity" settings so that offers appear in the "Service" type form.
Create a new Service with multiple offers and see how each offer gets a different Drupal node.
See the generated JSON-LD, notice how some of the metadata is missing because it's in the
corresponding offer page

{
"@type": "Service",
/* snip */
"offers": [
   {
      "@type": "Offer",
      "@url:": "/url/to/offer/1",
      "name": "Regular Pricing"
   },
   {
      "@type": "Offer",
      "@url:": "/url/to/offer/2",
      "name": "Academic Pricing"
   },
]
}

Proposed resolution

There should be a way of defining which types don't need new Drupal nodes, but instead get shown in their
parent page and embeded in the JSON-LD, like so:

{
"@type": "Service",
/* snip */
"offers": [
   {
      "@type": "Offer",
      "name": "Regular Pricing",
      "price": "500",
      "currency": "EUR"
   },
   {
      "@type": "Offer",
      "name": "Academic Pricing",
      "price": "100",
      "currency": "EUR",
      "eligibleCustomerType": {
       "@type": "BusinessEntityType".
       "name": "Academic"
     }
   },
]
}

In the last case, there's also a BusinessEntityType inside the Offer.

Remaining tasks

User interface changes

API changes

Data model changes

✨ Feature request
Status

Fixed

Version

1.0

Component

User interface

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • Status changed to Needs review over 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States jrockowitz Brooklyn, NY

    It is very tricky to determine what should and should not be included in a page's JSON-LD. Ideally, only the content displayed should be included.

    Currently, if a referenced Schema.org type is mapped to an entity with a public URL (i.e., node), the JSON-LD links to that entity. If a referenced Schema.org type is mapped to an entity without a public URL (i.e., paragraph), the JSON-LD includes all properties about that entity.

    One approach would be to add a flag/option to a mapping to determine whether the Schema.org type should be linked via @url or all the Schema.org properties should be included.

    BTW, there are a lot of hooks via schemadotorg_jsonld.api.php where you alter the JSON-LD to include and exclude Schema.org types and properties.

  • πŸ‡ΊπŸ‡ΈUnited States jrockowitz Brooklyn, NY

    Only a node will NOT include the reference entities Schema.org data. The decision/code for returning only an entity reference's node's URL is in \Drupal\schemadotorg_jsonld\SchemaDotOrgJsonLdBuilder::getSchemaPropertyFieldItem.

    My only thought or resolution would be to provide a configuration setting for determining which Schema.org types get referenced via URL or include the reference's data. For example, a common sense default would always include https://schema.org/Intangible entity references.

    On a related note, SchemaDotOrgJsonLdBuilder::getSchemaPropertyFieldItem is NOT entirely checking view access to the referenced node.

  • πŸ‡ΊπŸ‡ΈUnited States jrockowitz Brooklyn, NY

    I see three ways/types to include an entity reference view JSON-LD, URL, label, and entity.

    Below is an example of what the YAML via schemadotorg_jsonld.settings.yml for 'schema_type_entity_references' could look like

    Intangible: entity
    node--Thing: url
    taxonomy_term: label
    
  • @jrockowitz opened merge request.
  • Status changed to Fixed about 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States jrockowitz Brooklyn, NY
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024