Source of file HomePage.php
Size: 1,850 Bytes - Last Modified: 2021-12-23T10:51:36+00:00
/var/www/docs.ssmods.com/process/src/code/Pages/HomePage.php
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 | <?php class HomePage extends Page implements HiddenClass { static $db = array( ); static $has_many = array( ); /** * Change the home page to HomePage type */ function requireDefaultRecords() { if(!SiteTree::get_by_link("home")){ $homepage = new HomePage(); $$homepage->Title = "Home"; $homepage->URLSegment = "home"; $homepage->Sort = 1; $homepage->write(); $homepage->publish('Stage', 'Live'); $homepage->flushCache(); DB::alteration_message('Home Page created', 'created'); } else { $homepage = SiteTree::get_by_link("home"); if($homepage->ClassName != "HomePage") { $homepage = $homepage->newClassInstance("HomePage"); $homepage->write(); $homepage->publish('Stage', 'Live'); $homepage->flushCache(); DB::alteration_message('Home changed to HomePage', 'changed'); } } parent::requireDefaultRecords(); } } class HomePage_Controller extends Page_Controller { public function init() { parent::init(); } public function FeaturedPost(){ return $post = BlogEntry::get()->filter(array("IsFeatured" => 1))->sort("Date", "ASC")->First() ? $post : false; } public function LatestPosts($count = 6){ $post = BlogEntry::get()->sort("Date", "DESC"); if(is_null($count)) { return $post->count() ? $post : false; } else { return $post->count() ? $post->limit($count) : false; } } public function GetTestimonial() { return $testimonial = Testimonial::get()->sort("Created", "DESC")->First() ? $testimonial : false; } public function FeaturedHomes($count = null) { $listings = Listing::get()->filter(array("Status" => "Available", "Feature" => 1)); if(is_null($count)) { return $listings->count() ? $listings : false; } else { return $listings->count() ? $listings->limit($count) : false; } } } |