Created
September 27, 2016 01:15
-
-
Save sunnysideup/e4d866adbe1bbc5508c482373358bc4b to your computer and use it in GitHub Desktop.
page.ss
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Page extends SiteTree { | |
private static $has_many = array( | |
'Emails' => 'Page_Email' | |
); | |
/** | |
* CMS Fields | |
* @return FieldList | |
*/ | |
public function getCMSFields() | |
{ | |
$fields = parent::getCMSFields(); | |
$fields->addFieldToTab( | |
'Root.Emails', | |
GridField::create( | |
'Emails', | |
'Emails', | |
Page_Email::get(), | |
GridFieldConfig_RecordEditor::create() | |
) | |
); | |
return $fields; | |
} | |
} | |
class Page_Controller extends ContentController { | |
} | |
class Page_Email extends DataObject | |
{ | |
private static $db = array( | |
'Title' => 'EmailAddress' | |
); | |
private static $has_one = array( | |
'Page' => 'Page' | |
); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% loop $Emails %> | |
<ul id="emails"> | |
<li> | |
<a href="mailto:$Title.HiddenEmailAddress.RAW">$Title.HiddenEmailAddress.RAW</a> | |
</li> | |
</ul> | |
<% end_loop %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment