Source of file ABTestingPageExtension.php
Size: 1,414 Bytes - Last Modified: 2021-12-24T06:50:53+00:00
/var/www/docs.ssmods.com/process/src/code/ABTestingPageExtension.php
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 | <?php /** * Class ABTestingPageExtension */ class ABTestingPageExtension extends DataExtension { public static $db = array( 'ABTestPage' => 'Boolean', 'ABTestInlineScript' => 'Text' ); /** * Update the CMS fields on the extended object * * @param FieldList $fields */ public function updateCMSFields(FieldList $fields) { $member = Member::currentUser(); // lock down testing for heyday developers only if ($member->Email == Email::getAdminEmail()) { $fields->addFieldToTab( 'Root.ABTesting', new CheckboxField('ABTestPage', 'This is a page currently undergoing AB testing.') ); $fields->addFieldToTab( 'Root.ABTesting', new TextareaField('ABTestInlineScript', 'Inline Script for AB Testing (from Google content experiments)') ); } } /** * Provide a way to get the required script for AB testing into the template engine * * @return mixed */ public function getABTestScript() { if ($this->owner->ABTestPage) { if ($this->owner->ABTestInlineScript) { $html = new HTMLText(); $html->setValue($this->owner->ABTestInlineScript); return $html; } } return false; } } |