Advertisement
Guest User

Untitled

a guest
Aug 25th, 2010
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.13 KB | None | 0 0
  1. <?php
  2. class FAQCategory extends DataObject {
  3.  
  4.     static $db = array(
  5.         'FAQCategory' => 'Varchar(255)'
  6.     );
  7.  
  8.     static $has_many = array(
  9.         'FAQSubCategories' => "FAQSubCategory"
  10.     );
  11.  
  12.     public function getCMSFields($params = null) {
  13.         $fields = parent::getCMSFields($params);
  14.  
  15.         $fields->removeByName("FAQSubCategories");
  16.  
  17.         $fields->addFieldToTab("Root.Main",
  18.                 $manager =new DataObjectManager(
  19.                         $this,
  20.                         'FAQSubCategories',
  21.                         'FAQSubCategory',
  22.                         array(
  23.                                 'FAQSubCategory' => 'FAQSubCategory'
  24.                         )
  25.                 ));
  26.  
  27.         $manager->setAddTitle("FAQ Sub Categories");
  28.         $manager->set_popup_width(900);
  29.  
  30.         return $fields;
  31.     }
  32. }
  33.  
  34. class FAQSubCategory extends DataObject {
  35.  
  36.     static $db = array(
  37.         'FAQSubCategory' => 'Varchar(255)'
  38.     );
  39.  
  40.     static $has_one = array(
  41.         'Parent' => 'FAQCategory'
  42.     );
  43.  
  44.     static $has_many = array(
  45.         'FAQs' => "FAQ"
  46.     );
  47.  
  48.     public function getCMSFields($params = null) {
  49.         $fields = parent::getCMSFields($params);
  50.  
  51.         $fields->removeByName("FAQs");
  52.        
  53.         $fields->addFieldToTab("Root.Main",
  54.             $manager = new DataObjectManager(
  55.                 $this,
  56.                 'FAQs',
  57.                 'FAQ',
  58.                 array(
  59.                     'Question' => 'Question'
  60.                 )
  61.             )
  62.         );
  63.  
  64.         $manager->setAddTitle("FAQ");
  65.  
  66.     // This does not set the width
  67.         $manager->set_popup_width(800);
  68.  
  69.         return $fields;
  70.     }
  71. }
  72.  
  73. class FAQ extends DataObject {
  74.  
  75.     static $db = array(
  76.         'Question' => 'HTMLText',
  77.         'Answer' => 'HTMLText'
  78.     );
  79.     static $has_one = array(
  80.         'Parent' => 'FAQSubCategory',
  81.     );
  82.  
  83.     public function getCMSFields() {
  84.         $fields = new FieldSet();
  85.  
  86.         $fields->push(new SimpleHTMLEditorField("Question"));
  87.         $fields->push(new SimpleHTMLEditorField("Answer"));
  88.  
  89.         return $fields;
  90.     }
  91.  
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement