As per title, fetch/set LD Structured Data via getLdStructuredData() function in the Blog Entity, Blog Entry Entity, Page Entity and Series Entity.
UBS now uses the same standard as Thread Types and XFMG use to fetch/set LD Structured Data (and soon XFRM).
Here is an example (this is what the template code in the xa_ubs_blog_entry_view template looks like now. It uses extensions and a function call.
Quick example on how to use template extensions (use the XenForo Developers Forum if you want to learn more about template extensions in general). This example is used in the
And this is in the thread_view template. The above extension is passing data into the structured_data_extra_params extension, which will then be passed into the
Note: For those of you that don't know how to do things the modern way (template extensions and extending classes) and you want to customize the ldJsonHtml on your own, just copy the old ldJsonHtml template code before upgrading and replace the new template code with the old template code. Keep in mind, this is NOT supported, so doing that is an own your own type thing, just making sure that you are aware that you can do that
UBS now uses the same standard as Thread Types and XFMG use to fetch/set LD Structured Data (and soon XFRM).
Here is an example (this is what the template code in the xa_ubs_blog_entry_view template looks like now. It uses extensions and a function call.
HTML:
<xf:page option="ldJsonHtml">
<xf:extension name="structured_data_extra_params" value="{{ [] }}" />
<xf:extension name="structured_data">
<xf:set var="$ldJson"
value="{{ $blogEntry.getLdStructuredData($page, extension_value('structured_data_extra_params')) }}"
/>
<xf:if is="$ldJson">
<script type="application/ld+json">
{$ldJson|json(true)|raw}
</script>
</xf:if>
</xf:extension>
</xf:page>
Quick example on how to use template extensions (use the XenForo Developers Forum if you want to learn more about template extensions in general). This example is used in the
thread_view_type_question
template to pass in some additional structured data params to the thread_view
template which uses the same type of template code shown above...
HTML:
<xf:extends template="thread_view" />
<xf:extension name="structured_data_extra_params" value="{{ {
'highlightedPosts': $highlightedPosts,
'suggestedSolutions': $suggestedSolutions
} }}" />
And this is in the thread_view template. The above extension is passing data into the structured_data_extra_params extension, which will then be passed into the
getLdStructuredData
function in the Thread Entity.
HTML:
<xf:page option="ldJsonHtml">
<xf:extension name="structured_data_extra_params" value="{{ [] }}" />
<xf:extension name="structured_data">
<xf:set var="$ldJson"
value="{{ $thread.getLdStructuredData($firstPost, $page, extension_value('structured_data_extra_params')) }}"
/>
<xf:if is="$ldJson">
<script type="application/ld+json">
{$ldJson|json(true)|raw}
</script>
</xf:if>
</xf:extension>
</xf:page>
Note: For those of you that don't know how to do things the modern way (template extensions and extending classes) and you want to customize the ldJsonHtml on your own, just copy the old ldJsonHtml template code before upgrading and replace the new template code with the old template code. Keep in mind, this is NOT supported, so doing that is an own your own type thing, just making sure that you are aware that you can do that

Upvote
0