Announcement

Collapse
No announcement yet.

Adding json markup to Fragment for Brochure Pages when used for Articles

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Adding json markup to Fragment for Brochure Pages when used for Articles

    Brochure pages are great, unfortunately they don't automatically tell Google what the page represents, if you use Brochure Pages for articles, you can create a Fragment with the following layout (note the article will need to be within a single fragment, the image layout would be a full banner above the article content.)

    Create a new fragment layout and populate with:

    Code:
    <actinic:block if="%3cactinic%3avariable%20name%3d%22FragmentAnchor%22%20%2f%3e%20!=%20%22%22">
    <a name="<actinic:variable name="FragmentAnchor" />"></a>
    </actinic:block>
    <div class="fragment-text">
    <actinic:variable name="FragmentImage" />
    <p><strong>By <actinic:variable name='CompanyName' /></strong> | <actinic:variable name="ArticleDate" /></p><br />
    <actinic:variable name="FragmentText" />
    </div>
    
    <script type="application/ld+json">
    {
    "@context": "https://schema.org",
    "@type": "Article",
    "headline": "<actinic:variable name='FragmentTitle' />",
    "author": {
    "@type": "Organization",
    "name": "<actinic:variable name="CompanyName" />",
    "url": "<actinic:variable name="WebSiteURL" />"
    },
    "publisher": {
    "@type": "Organization",
    "name": "<actinic:variable name="CompanyName" />",
    "url": "<actinic:variable name="WebSiteURL" />",
    "logo": {
    "@type": "ImageObject",
    "url": "ENTER YOUR LOGO URL HERE"
    }
    },
    "datePublished": "<actinic:block php='true'>
    $date = '<actinic:variable name="ArticleDate" />';
    echo date('Y-m-d\TH:i:s\Z', strtotime($date . ' 10:00:00')); // Appends 10:00:00 as a default time
    </actinic:block>",
    "dateModified": "<actinic:block php='true'>
    $date = '<actinic:variable name="ArticleDate" />';
    echo date('Y-m-d\TH:i:s\Z', strtotime($date . ' 15:00:00')); // Appends 15:00:00 as a default time
    </actinic:block>",
    "mainEntityOfPage": {
    "@type": "WebPage",
    "@id": "<actinic:variable name='CanonicalPageURL' />"
    },
    "image": "URL/FOLDER/<actinic:variable name='FragmentImageFileNameRaw' />",
    "description": "<actinic:variable name='FragmentTitle' />.",
    "articleBody": <actinic:block php='true'>
    $sOriginal = '<actinic:variable encoding="perl" name="FragmentText" />';
    $sOriginal = preg_replace('/\{.*?\}/', ' ', $sOriginal); // Remove tabber headings
    $sOriginal = preg_replace('/\!\!<|>\!\!/', '', $sOriginal); // Remove !!< and >!!
    $sOriginal = strip_tags($sOriginal); // Remove HTML tags
    $sOriginal = html_entity_decode($sOriginal, ENT_QUOTES | ENT_HTML5, 'UTF-8'); // Convert HTML entities back to characters
    $sOriginal = str_replace('&', 'and', $sOriginal); // Replace '&' with 'and'
    $sOriginal = preg_replace('/[^a-zA-Z0-9\s.,!?-]/', '', $sOriginal); // Remove any remaining special characters
    echo json_encode(trim($sOriginal), JSON_UNESCAPED_UNICODE);
    </actinic:block>
    }
    </script>
    Fill in the highlighted bits with your own urls, these can be hard-coded as they will stay the same.

    You will need to create one variable: <actinic:variable name="ArticleDate" /> called ArticleDate set to fragment and enter the date in the following format on each article YYYY-MM-DD.
    Many Thanks
    Lee
    www.mdnsupplies.co.uk
    www.hookandloopfasteners.co.uk

    #2
    Excellent Lee. Thank you!
    Jonathan Chappell
    Website Designer
    SellerDeck Website Designer
    Actinic to SellerDeck upgrades
    Graphicz Limited - www.graphicz.co.uk

    Comment

    Working...
    X