5102 Posts in 1520 Topics by 1116 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 772 Views |
-
Add Function & CMS Field ONLY to Menu Pages

30 May 2010 at 5:34am
I have this code for Page.php
class Page extends SiteTree {
public static $db = array(
);
public static $has_one = array(
'MenuImg' => 'Image',
'MenuImg2' => 'Image'
);
function getCMSFields()
{
$fields = parent::getCMSFields();
$fields->addFieldToTab("Root.Content.MenuImages", new ImageField('MenuImg','Menu Image'));
$fields->addFieldToTab("Root.Content.MenuImages", new ImageField('MenuImg2','Menu Image Rollover'));return $fields;
}
}I only want the "Menu Images" tab to appear in the CMS on pages that are ticked "Show in Menus" is this possible thanks!?
-
Re: Add Function & CMS Field ONLY to Menu Pages

30 May 2010 at 11:40am
Perhaps use
$fields = parent::getCMSFields();
if($this->ShowInMenus) {
$fields->addFieldToTab("Root.Content.MenuImages", new ImageField('MenuImg','Menu Image'));
$fields->addFieldToTab("Root.Content.MenuImages", new ImageField('MenuImg2','Menu Image Rollover'));
}return $fields;
} -
Re: Add Function & CMS Field ONLY to Menu Pages

30 May 2010 at 7:54pm
Works like a charm! thank you!!
| 772 Views | ||
|
Page:
1
|
Go to Top |


