Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 25th, 2010  |  syntax: PHP  |  size: 2.13 KB  |  hits: 152  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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. }