<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
sunnysideup / silverstripe-externalurlfield example snippets
use SilverStripe\ORM\DataObject;
class MyDataObject extends DataObject
{
private static $db = array(
'Website' => 'ExternalURL(768)', // set a max length so that we can index it - if you do not need to index it then you may not need to add this.
);
}
use Sunnysideup\ExternalURLField\ExternalURLField;
//default
$websitefield = new ExternalURLField('Website');
//set options (with defaults shown)
$websitefield->setConfig(array(
//these will be added, if missing
'defaultparts' => array(
'scheme' => 'http'
),
//these parts are removed from saved urls
'removeparts' => array(
'scheme' => false,
'user' => true,
'pass' => true,
'host' => false,
'port' => false,
'path' => false,
'query' => false,
'fragment' => false
),
'html5validation' => true
));
//say you want to store nice tidy facebook urls
$websitefield->setConfig('removeparts',array(
'query' => true,
'fragment' => 'true',
'port' => 'true'
));
//a urls like https://www.facebook.com/joe.bloggs?fref=nf&pnref=story
//would become https://www.facebook.com/joe.bloggs
$field->setConfig("html5validation", false);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.