XF 2.3 How to add custom schema?

Hello, I want to add a custom schema of books for XFRM items.
What I have done so far is update the xfrm_resource_view

Code:
<xf:macro template="metadata_macros" name="metadata"
    arg-type="books.book"
    arg-description="{$descSnippet}"
    arg-shareUrl="{{ link('canonical:resources', $resource) }}"
    arg-canonicalUrl="{{ link('canonical:resources', $resource) }}"
    arg-imageUrl="{{ $resource.getCoverImage() ?: ($resource.getIconUrl('l', true) ?: $xf.options.defaultMetaImage) }}" />

<xf:page option="ldJsonHtml">
<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "Book",
  "bookFormat": "PDF",
  "inLanguage": "{{$resource.custom_fields.Language}}",
  "numberOfPages": "{{$resource.custom_fields.numberOfPages}}",
  "isbn": "{{$resource.custom_fields.ISBN}}",
  "sameAs": "{{$resource.custom_fields.Wiki}}",
  "genre": "{{ $resource.Prefix.title }}",
  "image": "{{ $resource.getIconUrl('s', true)|escape('json') }}",
  "bookEdition": "1st Edition",
  "@id": "{{ link('canonical:resources', $resource)|escape('json') }}",
  "name": "{$resource.title|escape('json')}",
  "headline": "{$resource.title|escape('json')}",
  "alternativeHeadline": "{$resource.tag_line|escape('json')}",
  "description": "{$descSnippet|escape('json')}",
  "dateCreated": "{{ date($resource.resource_date, 'c')|escape('json') }}",
  "dateModified": "{{ date($resource.last_update, 'c')|escape('json') }}",
  "isAccessibleForFree": true,
  "audience": "Religious",
  "author": {
    "@type": "Person",
    "name": "{{$resource.custom_fields.author}}"
  },
  "potentialAction": {
    "@type": "Action",
    "name": "Download PDF",
    "target": {
      "@type": "EntryPoint",
      "urlTemplate": "{{ link('canonical:resources', $resource)|escape('json') }}download"
    }
  },
  <xf:if is="$xf.options.xfrmAllowIcons AND $resource.icon_date">
    "thumbnailUrl": "{{ $resource.getIconUrl('l', true)|escape('json') }}",
  </xf:if>
  <xf:if is="$resource.rating_count">
    "aggregateRating": {
      "@type": "AggregateRating",
      "ratingCount": "{$resource.rating_count|escape('json')}",
      "ratingValue": "{$resource.rating_avg|escape('json')}"
    },
  </xf:if>
  <xf:if is="$resource.hasViewableDiscussion()">
    "discussionUrl": "{{ link('canonical:threads', $resource.Discussion)|escape('json') }}",
  </xf:if>
  "publisher": {
    "@type": "Organization",
    "name": "{{$resource.custom_fields.Publisher}}"
  },
  "offers": {
    "@type": "Offer",
    "url": "{{ link('canonical:resources', $resource)|escape('json') }}",
    "price": "0",
    "priceCurrency": "USD",
    "availability": "http://schema.org/InStock"
  }
}
</script>
  <script type="application/ld+json">
    {
      "@context": "https://schema.org",
      "@type": "WebSite",
      "name": "Website Title",
      "url": "https://domain.com/",
      "potentialAction": {
        "@type": "SearchAction",
        "target": "https://domain.com/search/search?keywords={search_term_string}",
        "query-input": "required name=search_term_string"
      }
    }
  </script>

</xf:page>

with this, ensure it's working and valid on the schema validator.

Unfortunately, Google doesn't detect these schemas on https://search.google.com/test/rich-results
Instead, it only detects two BreadcrumbList with Unnamed items.

1735902613892.webp

How can I fix this?

Thank you so much for your time.
 
Back
Top Bottom