Advertisement
smaction

Youtube.php

Mar 20th, 2014
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.26 KB | None | 0 0
  1. <?php
  2. /**
  3.  *
  4.  */
  5. class RamsheadYoutube extends SiteTree{
  6.     //THIS PAGE CAN NOT BE CREATED AS A TOP LEVEL PAGE
  7.         static $can_be_root = false;
  8.     //ALLOWED CHILD PAGES
  9.         static $allowed_children = "none";
  10.     //
  11.         static $db = array (
  12.             'Title' => 'Text',
  13.             'YoutubeID' => 'Text'
  14.         );
  15.     //
  16.         static $has_one = array(    
  17.         );
  18.     //
  19.         static $defaults = array (
  20.             'ShowInMenus' => false,
  21.             'ShowInSearch' => false
  22.         );
  23.        
  24.     /**/
  25.     function getCMSFields(){
  26.         $fields = parent::getCMSFields();
  27.        
  28.         //REMOVE FIELDS THAT ARE NOT NEEDED
  29.             $fields->removeByName('Metadata');
  30.             $fields->removeByName('GoogleSitemap');
  31.             $fields->removeFieldFromTab('Root.Content.Main', 'MenuTitle');
  32.             $fields->removeFieldFromTab("Root.Content.Main", "Content");
  33.        
  34.         //
  35.             $fields->addFieldToTab("Root.Content.Main", new TextField('Title', 'Title'));
  36.             $fields->addFieldToTab("Root.Content.Main", new TextField('YoutubeID', 'Youtube ID'));
  37.        
  38.  
  39.         return $fields;
  40.     }
  41. }
  42. /**/
  43. class RamsheadYoutube_Controller extends ContentController{
  44.    
  45.     /**/
  46.     public static $allowed_actions = array(
  47.     );
  48.    
  49.     /**/
  50.     public function init(){
  51.         parent::init();
  52.         //
  53.             if( $this->dataRecord->hasExtension('Translatable') ){
  54.                 i18n::set_locale($this->dataRecord->Locale);
  55.             }
  56.     }
  57.    
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement