• REGISTRATION REQUIREMENTS:

    Your username here MUST MATCH your XenForo username (connected to your XF license).

    Once you have registered here, then you need to start a conversation at xenforo.com w/Bob and provide the following:
    1. Your XenForo License Validation Token
    2. The Domain Name associated with the License
    NOTE: Your account will be validated once ALL requirements are verified/met. Thank you for your patience.

Implemented Fetch LD Structured Data via getLdStructuredData() function in the Event & Bet Entities

Bob

Developer
Staff member
As per title, fetch/set LD Structured Data via getLdStructuredData() function in the Event Entity and Bet Entity.

Sportsbook now uses the same standard as Thread Types and XFMG use to fetch/set LD Structured Data for both Events and Bets

Here is an example (this is what the template code in the xa_sb_event_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="{{ $event.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>
 
Upvote 0
This suggestion has been implemented. Votes are no longer accepted.
Back
Top