\URLSegmented
URLSegmented
Takes care of adding an unique url segment to dataobjects
attach either via
static $extensions = array("URLSegmented");
from within a DataObject or via
Object::add_extension("MyDataObject", "URLSegmented");
from your _config.php
If you'd like to make use of the DataList::get()->byURL($URLSegment) helper, add this line to your _config
Object::add_extension("DataList", "URLSegmented_DataListExtension");
PHP version 5.3+
- Author: Tim Klein<tim[at]dodat.co.nz>
- Copyright: 2013 Dodat Ltd.
Synopsis
class URLSegmented
extends DataExtension
{
- // members
- private $Scope;
- private $TitleField;
- // methods
- public void __construct()
- public static void get_extra_config()
- public void onBeforeWrite()
- public void generateURLSegment()
- public void setURLSegment()
- public void existsInScope()
- public void addScopeCheck()
Hierarchy
Extends
- DataExtension
Members
private
- $Scope
- $TitleField
Methods
public
- __construct()
- addScopeCheck()
- existsInScope() — checks wether the provided param urlSegment exists in the given scope returns bool
- generateURLSegment() — just a simple method that sets a default url segment title
- get_extra_config()
- onBeforeWrite()
- setURLSegment() — custom setter for urlsegment runs param through urlsegment filter to sanitize any unwanted characters calls existsInScope for uniqueness check, otherwise appends random number until unique