1. Go to this page and download the library: Download nightjar/ss-slug 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/ */
nightjar / ss-slug example snippets
namespace MyVendor\MyNamespace;
use SilverStripe\ORM\DataObject;
use Nightjar\Slug\Slug;
class Item extends DataObject {
private static $extensions = [
Slug::class . '("Title", "Parent", true)' // Apply Extension!
];
private static $db = [
'Title' => 'Varchar'
];
private static $has_one = [
'Parent' => 'ItemsPage'
];
public function Link() { // Will override extension's Link() method
return $this->Parent()->Link($this->URLSlug);
}
}
namespace MyVendor\MyNamespace;
use Page;
class ItemsPage extends Page {
private static $has_many = [
'Items' => 'Item'
];
}
namespace MyVendor\MyNamespace;
use PageController;
use Nightjar\Slug\SlugHandler;
class ItemsPageController extends PageController {
private static $extensions = [
SlugHandler::class
];
}
namespace MyVendor\MyNamespace;
use PageController;
use Nightjar\Slug\SlugHandler;
class ItemsPageController extends PageController {
private static $extensions = [
SlugHandler::class . '("MyItems")'
];
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.