PHP code example of jonom / silverstripe-custom-errors

1. Go to this page and download the library: Download jonom/silverstripe-custom-errors 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/ */

    

jonom / silverstripe-custom-errors example snippets


if ($somethingWentWrong) {
    $this->customError(404, [
        'Title' => 'We couldn\'t find the droids you are looking for',
        'Content' => DBField::create_field('HTMLText', '<p>Please try another Cantina</p>')
    ]);
}

$this->customError(404, [
    'Content' => DBField::create_field('HTMLText', '<p>Maybe try the Google</p>')
]);

$this->customError(
    404,
    [
        'Content' => DBField::create_field('HTMLText', '<p>Here are some other droids you may be interested in:</p>'),
        'Droids' => Droid::get()->filterAny(['Language' => 'Beeps', 'Color' => 'Gold'])->limit(5)
    ],
    'DroidHolder',
    'DroidHolderController'
);