PHP code example of vulcandigital / silverstripe-seo

1. Go to this page and download the library: Download vulcandigital/silverstripe-seo library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

vulcandigital / silverstripe-seo example snippets




namespace Vendor\Project\Analysis;

use QuinnInteractive\Seo\Analysis\Analysis;

class HelloWorldTitleAnalysis extends Analysis
{
    const FAILED = 0;
    const SUCCESS = 1;

    public function run()
    {
        if (!strstr($this->getPage()->Title, 'Hello World!')) {
            return static::FAILED;
        }

        return static::SUCCESS;
    }

    public function responses()
    {
        return [
            static::FAILED  => ['The string "Hello World!" does not appear in the page title', 'danger'],
            static::SUCCESS => ['Hoorah!!! "Hello World!" appears in the page title', 'success'],
        ];
    }
}

private static $hidden_levels = [
    'success'
];

public function seoContentFields()
{
    return [
        'Content',
        'MyBlock.Title',
        'MyBlock.Content',
        'BottomTitle',
        'BottomContent',
    ];
}

public function updateCollateContentFields($content) {
    // Content is an array of strings with content in the order in which they appear to the user
    $content[] = 'This is example content';
    return $content;
}
yml
QuinnInteractive\Seo\Extensions\PageSeoExtension:
    enable_creator_tag: false