Last active
August 29, 2015 14:04
-
-
Save muskie9/e765bc4b94c4d3e11b4d to your computer and use it in GitHub Desktop.
PageLink dropdown relation for linking in Layout
This file contains 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 HomePage extends Page { | |
private static $has_one = array( | |
'PageLink' => 'SiteTree' | |
); | |
public function getCMSFields() { | |
$fields = parent::getCMSFields(); | |
$fields->addFieldToTab('Root.Main', new TreeDropdownField("PageLinkID", "Page to link to", "SiteTree"), 'Content'); | |
$this->extend('updateCMSFields', $fields); | |
return $fields; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You would then use
<a href="$PageLink.Link">$PageLink.Title</a>
in the Layout of that page type