Source of file TestimonialWidget.php
Size: 0,873 Bytes - Last Modified: 2021-12-23T10:11:29+00:00
/var/www/docs.ssmods.com/process/src/TestimonialWidget.php
12345678910111213141516171819202122232425262728293031323334 | <?php class TestimonialWidget extends Widget { private static $title = "Testimonial"; private static $cmsTitle = "Testimonial"; private static $description = "Displays a random testimonial from the database"; private static $has_one = array( 'Page' => 'TestimonialsHolderPage' ); protected $testimonial; public function getTestimonial() { if (!$this->testimonial) { $this->testimonial = Testimonial::get()->sort("RAND()")->first(); } return $this->testimonial; } public function getCMSFields() { $fields = parent::getCMSFields(); $fields->push( DropdownField::create("PageID", "Testimonials Holder Page", TestimonialsHolderPage::get()->map()->toArray() )->setHasEmptyDefault(true) ); return $fields; } } |