Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Upgrading SilverStripe

Ask questions about upgrading SilverStripe to the latest version.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

nestedurls - upgrade to 2.4.0 breaks old url schema - (possible bug and solution)


12 Posts   2072 Views


15 May 2010 at 3:23am Community Member, 110 Posts

Ingo, tx for replying

The series are DataObjects, i will post my code below.

The meaning of it all....I stream videos on an Internal Network ( among other stuff i present on the webpage ), so i provide a webpage for people to look trough the series and pick a episode to watch. Everybody loves the way it works ( tx SilverStripe guys ).
Offcourse i could stay with 2.3.7. but i want to move on.....

-----------------Code Video--------------------------

class Video extends DataObject {
    static $db = array(
'Name' => 'Varchar',
    'Server' => 'VarChar',
    'Folder' => 'VarChar',
    'Omschrijving' => 'Text',
    'URLSegment' => 'Varchar(255)');

   static $has_one = array(
      'VideoPage' => 'VideoPage',
      'Photo' => 'Image');   
    static $has_many = array(
            'VideoCats' => 'VideoCat',
            'VideoStreams' => 'VideoStream');
   public function getCMSFields(){
    return new FieldSet(
       new TextField('Name'),
         new TextField('Server'),
         new TextField('Folder'),
         new TextareaField('Omschrijving'),
         new ImageField('Photo', 'COVER'),
            new DataObjectManager(
               array('Name' => 'Naam', )));
   public function getThumb(){
         return $this->Photo()->CMSThumbnail();
         return '(No Photo)';
   public function getLinkingMode(){
      if($this->URLSegment == Director::URLParam('Action')){
         return 'current';
         return 'link';

public function onBeforeWrite(){


$this->URLSegment = SiteTree::GenerateURLSegment($this->Name);

if($object = DataObject::get_one($this->ClassName, "URLSegment='".$this->URLSegment."' AND ID !=".$this->ID)){

$this->URLSegment = $this->URLSegment.'-'.$this->ID;


} else {

$this->URLSegment = SiteTree::GenerateURLSegment($this->ClassName.'-'.$this->ID);



---------------------- end of code Video ------------------

---------------------- code VideoCat ----------------------

class VideoCat extends DataObject {

   static $db = array('Name' => 'Varchar');

   static $has_one = array('Video' => 'Video');

   static $has_many = array('VideoStreams' => 'VideoStream');

function getCMSFields() {
   return new FieldSet(
         new TextField('Name', 'Categorie '),
         new DataObjectManager(


------------------- end of code VideoCat ---------------------------

------------------- code VideoStream --------------------------------

class VideoStream extends DataObject {

   static $db = array('Name' => 'Varchar');

static $has_one = array(
   'Video'=> 'Video',
'VideoCat' => 'VideoCat');

function getCMSFields() {
   return new FieldSet(
         new TextField('Name', 'exacte naam van het file, ZONDER extensie'));

--------------- end of Code VideoStream --------------------------------

--------------- Code VideoPage -----------------------------------------

class VideoPage extends Page {
static $has_many = array('Videos' => 'Video');
function getCMSFields() {
   $fields = parent::getCMSFields();

   $dataobjectmanager = new HasManyDataObjectManager(
      array('Thumb' => 'Photo', 'Name' => 'Name','Server' => 'Server', 'Folder' => 'Folder', 'Omschrijving' => 'Omschrijving'),
   $dataobjectmanager->setPluralTitle("een video");
   $fields->addFieldToTab("Root.Content.Video", $dataobjectmanager);
   return $fields;

class VideoPage_Controller extends Page_Controller {
function init(){

   public function getIndividualVideo(){
      if($URLAction = Director::URLParam('Action')){

         $VideoID = Convert::raw2xml($URLAction);
         if($VideoID ){
            return DataObject::get_one('Video', "URLSegment='".$VideoID."'");
---------------------- end of Code VideoPage --------------------------


16 May 2010 at 12:38pm Forum Moderator, 801 Posts

Sorry, that still doesnt explain how you expect your Director rules to work. You must have a Director::addRules() command somewhere to have something like "series/1" work in the first place, right?


16 May 2010 at 8:15pm (Last edited: 16 May 2010 8:20pm), Community Member, 110 Posts

Tx, but no... i don't use the Director::addRules() command as far as i know. At least i didn't put it anywhere.... But doesn't my Public function 'getindividualVideo' takes care at providing the link.?

ps: You can tell i'm a total beginner at this right? ;)


5 August 2010 at 5:44am 4085 Posts

I think you're misusing the URL action. Based on your code, you're placing the video ID in the Action param. That doesn't work anymore in 2.4. Actions have to be functions.

So you'll need to create an action like:

function show() {
// get video based on request param "ID"

return array (
'Video' => $video

I assume "series" is your URLSegment?