I change it like you ask me But It doesn't work
<?php
/**
* Defines the homePage page type
*/
class homePage extends SiteTree {
static $allowed_children = "none";
static $db = array(
'Address' => 'HTMLText',
'SlideDescriptionShort1' => 'Text',
'SlideDescriptionLong1' => 'Text',
'SlideDescriptionShort2' => 'Text',
'SlideDescriptionLong2' => 'Text',
'SlideDescriptionShort3' => 'Text',
'SlideDescriptionLong3' => 'Text',
'SlideDescriptionShort4' => 'Text',
'SlideDescriptionLong4' => 'Text',
'SlideDescriptionShort5' => 'Text',
'SlideDescriptionLong5' => 'Text',
'SlideDescriptionShort6' => 'Text',
'SlideDescriptionLong6' => 'Text',
'SlideDescriptionShort7' => 'Text',
'SlideDescriptionLong7' => 'Text',
'SlideDescriptionShort8' => 'Text',
'SlideDescriptionLong8' => 'Text',
'DomesticTitle' => 'Text',
'DomesticTagline' => 'Text',
'ProfessonialTitle' => 'Text',
'ProfessonialTagline' => 'Text',
'NewPanelTitle' => 'Text',
'NewPanelTagline' => 'Text',
'NewProductTitle' => 'Text',
'NewProductTagline' => 'Text',
'OurProductTitle' => 'Text',
'OurProductTagline' => 'Text',
'PublicationsTitle' => 'Text',
'PublicationsTagline' => 'Text',
);
static $has_many = array(
'UsedBy' => 'Sponsor'
);
public static $has_one = array(
'SlideImage1' => 'Image',
'SlideImage2' => 'Image',
'SlideImage3' => 'Image',
'SlideImage4' => 'Image',
'SlideImage5' => 'Image',
'SlideImage6' => 'Image',
'SlideImage7' => 'Image',
'SlideImage8' => 'Image',
'SlidePage1' => 'SiteTree',
'SlidePage2' => 'SiteTree',
'SlidePage3' => 'SiteTree',
'SlidePage4' => 'SiteTree',
'SlidePage5' => 'SiteTree',
'SlidePage6' => 'SiteTree',
'SlidePage7' => 'SiteTree',
'SlidePage8' => 'SiteTree',
'DomesticLink' => 'SiteTree',
'DomesticImage' => 'Image',
'ProfessonialLink' => 'SiteTree',
'ProfessonialImage' => 'Image',
'NewPanelLink' => 'SiteTree',
'NewPanelImage' => 'Image',
'NewProductLink' => 'SiteTree',
'NewProductImage' => 'Image',
'OurProductLink' => 'SiteTree',
'OurProductImage' => 'Image',
'PublicationsLink' => 'SiteTree',
'PublicationsImage' => 'Image',
);
function getCMSFields() {
$fields = parent::getCMSFields();
// add field to edit footer and address section
$fields->addFieldToTab("Root.Content.Address", new HTMLEditorField('Address', 'Address'));
// Slides
// Slide 1
$fields->addFieldToTab('Root.Content.Slides', new LiteralField ($name = "literalfield", $content = "<h2>Left Slide Window</h2>"));
$fields->addFieldToTab('Root.Content.Slides', new LiteralField ($name = "literalfield", $content = "<h4>Slide 1</h4>"));
$fields->addFieldToTab('Root.Content.Slides', new TextField('SlideDescriptionShort1', 'Short description'));
$fields->addFieldToTab('Root.Content.Slides', new TextField('SlideDescriptionLong1', 'Long description'));
$fields->addFieldToTab('Root.Content.Slides', new TreeDropdownField('SlidePage1ID', 'Page', 'SiteTree'));
$fields->addFieldToTab("Root.Content.Slides", new UploadField('SlideImage1', 'Image'));
// $fields->addFieldToTab("Root.Content.Slides", new UploadField('Image', 'Image'));
//$fields->addFieldToTab("Root.Content.Slides", new UploadField('Image', 'Image'));
// Slide 2
$fields->addFieldToTab('Root.Content.Slides', new LiteralField ($name = "literalfield", $content = "<h4 style=\"margin:10px 0 0;\">Slide 2</h4>"));
$fields->addFieldToTab('Root.Content.Slides', new TextField('SlideDescriptionShort2', 'Short description'));
$fields->addFieldToTab('Root.Content.Slides', new TextField('SlideDescriptionLong2', 'Long description'));
$fields->addFieldToTab('Root.Content.Slides', new TreeDropdownField('SlidePage2ID', 'Page', 'SiteTree'));
$fields->addFieldToTab("Root.Content.Slides", new UploadField('SlideImage2', 'Image'));
// Slide 3
$fields->addFieldToTab('Root.Content.Slides', new LiteralField ($name = "literalfield", $content = "<h4 style=\"margin:10px 0 0;\">Slide 3</h4>"));
$fields->addFieldToTab('Root.Content.Slides', new TextField('SlideDescriptionShort3', 'Short description'));
$fields->addFieldToTab('Root.Content.Slides', new TextField('SlideDescriptionLong3', 'Long description'));
$fields->addFieldToTab('Root.Content.Slides', new TreeDropdownField('SlidePage3ID', 'Page', 'SiteTree'));
$fields->addFieldToTab("Root.Content.Slides", new UploadField('SlideImage3', 'Image'));
// Slide 4
$fields->addFieldToTab('Root.Content.Slides', new LiteralField ($name = "literalfield", $content = "<h4 style=\"margin:10px 0 0;\">Slide 4</h4>"));
$fields->addFieldToTab('Root.Content.Slides', new TextField('SlideDescriptionShort4', 'Short description'));
$fields->addFieldToTab('Root.Content.Slides', new TextField('SlideDescriptionLong4', 'Long description'));
$fields->addFieldToTab('Root.Content.Slides', new TreeDropdownField('SlidePage4ID', 'Page', 'SiteTree'));
$fields->addFieldToTab("Root.Content.Slides", new UploadField('SlideImage4', 'Image'));
$fields->addFieldToTab('Root.Content.Slides', new LiteralField ($name = "literalfield", $content = "<h2>Right Slide Window</h2>"));
// Slide 5
$fields->addFieldToTab('Root.Content.Slides', new LiteralField ($name = "literalfield", $content = "<h4>Slide 1</h4>"));
$fields->addFieldToTab('Root.Content.Slides', new TextField('SlideDescriptionShort5', 'Short description'));
$fields->addFieldToTab('Root.Content.Slides', new TextField('SlideDescriptionLong5', 'Long description'));
$fields->addFieldToTab('Root.Content.Slides', new TreeDropdownField('SlidePage5ID', 'Page', 'SiteTree'));
$fields->addFieldToTab("Root.Content.Slides", new UploadField('SlideImage5', 'Image'));
// Slide 6
$fields->addFieldToTab('Root.Content.Slides', new LiteralField ($name = "literalfield", $content = "<h4 style=\"margin:10px 0 0;\">Slide 2</h4>"));
$fields->addFieldToTab('Root.Content.Slides', new TextField('SlideDescriptionShort6', 'Short description'));
$fields->addFieldToTab('Root.Content.Slides', new TextField('SlideDescriptionLong6', 'Long description'));
$fields->addFieldToTab('Root.Content.Slides', new TreeDropdownField('SlidePage6ID', 'Page', 'SiteTree'));
$fields->addFieldToTab("Root.Content.Slides", new UploadField('SlideImage6', 'Image'));
// Slide 7
$fields->addFieldToTab('Root.Content.Slides', new LiteralField ($name = "literalfield", $content = "<h4 style=\"margin:10px 0 0;\">Slide 3</h4>"));
$fields->addFieldToTab('Root.Content.Slides', new TextField('SlideDescriptionShort7', 'Short description'));
$fields->addFieldToTab('Root.Content.Slides', new TextField('SlideDescriptionLong7', 'Long description'));
$fields->addFieldToTab('Root.Content.Slides', new TreeDropdownField('SlidePage7ID', 'Page', 'SiteTree'));
$fields->addFieldToTab("Root.Content.Slides", new UploadField('SlideImage7', 'Image'));
// Slide 8
$fields->addFieldToTab('Root.Content.Slides', new LiteralField ($name = "literalfield", $content = "<h4 style=\"margin:10px 0 0;\">Slide 4</h4>"));
$fields->addFieldToTab('Root.Content.Slides', new TextField('SlideDescriptionShort8', 'Short description'));
$fields->addFieldToTab('Root.Content.Slides', new TextField('SlideDescriptionLong8', 'Long description'));
$fields->addFieldToTab('Root.Content.Slides', new TreeDropdownField('SlidePage8ID', 'Page', 'SiteTree'));
$fields->addFieldToTab("Root.Content.Slides", new UploadField('SlideImage8', 'Image'));
$tablefield = new HasManyComplexTableField(
$this,
'UsedBy',
'Sponsor',
array( 'Thumbnail' => 'Image', 'CompanyName' => 'Company Name'),
'getCMSFields_forPopup'
);
$tablefield->setAddTitle( 'A Product User' );
// $fields->addFieldToTab( 'Root.Content.ProductUser', $tablefield );
$fields->addFieldToTab('Root.Content.NewsletterPanels', new LiteralField ("literalfield", "<h3>Domestic Newsletter Panel</h3>"));
$fields->addFieldToTab('Root.Content.NewsletterPanels', new TextField('DomesticTitle', 'Domestic Title'));
$fields->addFieldToTab('Root.Content.NewsletterPanels', new TextField('DomesticTagline', 'Domestic Tagline'));
$fields->addFieldToTab('Root.Content.NewsletterPanels', new TreeDropdownField('DomesticLinkID', 'Domestic Link', 'SiteTree'));
$fields->addFieldToTab("Root.Content.NewsletterPanels", new UploadField('DomesticImage', 'Domestic Image'));
$fields->addFieldToTab('Root.Content.NewsletterPanels', new LiteralField ("literalfield", "<h3>Professional Newsletter Panel</h3>"));
$fields->addFieldToTab('Root.Content.NewsletterPanels', new TextField('ProfessonialTitle', 'Professional Title'));
$fields->addFieldToTab('Root.Content.NewsletterPanels', new TextField('ProfessonialTagline', 'Professional Tagline'));
$fields->addFieldToTab('Root.Content.NewsletterPanels', new TreeDropdownField('ProfessonialLinkID', 'Professional Link', 'SiteTree'));
$fields->addFieldToTab("Root.Content.NewsletterPanels", new UploadField('ProfessonialImage', 'Professional Image'));
$fields->addFieldToTab('Root.ProductsPanels', new LiteralField ("literalfield", "<h3>New Newsletter Panel</h3>"));
$fields->addFieldToTab('Root.ProductsPanels', new TextField('NewPanelTitle', 'New Panel Title'));
$fields->addFieldToTab('Root.ProductsPanels', new TextField('NewPanelTagline', 'New Panel Tagline'));
$fields->addFieldToTab('Root.ProductsPanels', new TreeDropdownField('NewPanelLinkID', 'New Panel Link', 'SiteTree'));
$fields->addFieldToTab("Root.ProductsPanels", new UploadField('NewPanelImage', 'New Panel Image'));
$fields->addFieldToTab('Root.ProductsPanels', new LiteralField ("literalfield", "<h3>New Product Panel</h3>"));
$fields->addFieldToTab('Root.ProductsPanels', new TextField('NewProductTitle', 'New Product Title'));
$fields->addFieldToTab('Root.ProductsPanels', new TextField('NewProductTagline', 'New Product Tagline'));
$fields->addFieldToTab('Root.ProductsPanels', new TreeDropdownField('NewProductLinkID', 'New Product Link', 'SiteTree'));
$fields->addFieldToTab("Root.ProductsPanels", new UploadField('NewProductImage', 'New Product Image'));
$fields->addFieldToTab('Root.ProductsPanels', new LiteralField ("literalfield", "<h3>Our Products Panel</h3>"));
$fields->addFieldToTab('Root.ProductsPanels', new TextField('OurProductTitle', 'Our Product Title'));
$fields->addFieldToTab('Root.ProductsPanels', new TextField('OurProductTagline', 'Our Product Tagline'));
$fields->addFieldToTab('Root.ProductsPanels', new TreeDropdownField('OurProductLinkID', 'Our Product Link', 'SiteTree'));
$fields->addFieldToTab("Root.ProductsPanels", new UploadField('OurProductImage', 'Our Product Image'));
$fields->addFieldToTab('Root.Content.PublicationsPanel', new LiteralField ("literalfield", "<h3>Publications Panel</h3>"));
$fields->addFieldToTab('Root.Content.PublicationsPanel', new TextField('PublicationsTitle', 'Publications Title'));
$fields->addFieldToTab('Root.Content.PublicationsPanel', new TextField('PublicationsTagline', 'Publications Tagline'));
$fields->addFieldToTab('Root.Content.PublicationsPanel', new TreeDropdownField('PublicationsLinkID', 'Publications Link', 'SiteTree'));
$fields->addFieldToTab("Root.Content.PublicationsPanel", new UploadField('PublicationsImage', 'Publications Image'));
return $fields;
}
function LeftFeatureImage($width=30, $height=30) {
$Image = $this->SlideImage1();
if ( $Image ) {
if($Image->getWidth() > $width) {
return $Image->CroppedImage($width, $height);
} else {
return $Image;
}
} else {
return null;
}
}
function RightFeatureImage($width=30, $height=30) {
$Image = $this->SlideImage5();
if ( $Image ) {
if($Image->getWidth() > $width) {
return $Image->CroppedImage($width, $height);
} else {
return $Image;
}
} else {
return null;
}
}
function LightBox()
{
if (isset($_COOKIE['Lightbox']))
$cookie = 'none';
else
$cookie = 'block';
return $cookie;
}
}
class homePage_Controller extends Page_Controller {
// Latest News
function LatestNews($num=3) {
$news = DataObject::get_one("NewsPageHolder");
return ($news) ? DataObject::get("NewsPage", "ParentID = $news->ID", "Date DESC", "", $num) : false;
}
// Latest Events
function ComingEvents($num=3) {
$event = DataObject::get_one("EventPageHolder");
$yesterday = date('Y-m-d',mktime(0,0,0,date('m'), date('d')-1, date('Y')));
return ($event) ? DataObject::get("EventPage", "`ParentID` = '".$event->ID."' and Date > '{$yesterday}'", "Date DESC", "", $num) : false;
}
}
?>