Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Adding an Images Tab in the backend


Reply


2 Posts   948 Views

Avatar
barrycorrigan

Community Member, 10 Posts

29 March 2011 at 11:13pm

Hi Everyone,

Having a bit of a problem that I hope someone could help me out with. Im trying to add an images tab in the backend. So the page is called PartnersPage.php and here is what i've added:

<?php

class PartnersPage extends Page {
static $db = array(
      'Heading' => 'Text',
      'SubHeading' => 'Text',
      'WebLink' => 'Text'
);
static $has_one = array(
   'TopPhoto' => 'Image'

);

function getCMSFields() {
$fields = parent::getCMSFields();

$fields->addFieldToTab('Root.Content.Main', new TextField('Heading'), 'Content');
      $fields->addFieldToTab('Root.Content.Main', new TextField('SubHeading'), 'Content');
      $fields->addFieldToTab('Root.Content.Main', new TextField('WebLink'), 'Content');
      
      $fields->addFieldToTab("Root.Content.Images", new ImageField('TopPhoto'));

return $fields;
}
}

class PartnersPage_Controller extends Page_Controller {

}

But as soon as I add the Image Field the website goes down and says

"Sorry, there was a problem with handling your request.
Visit www.silverstripe.org to download the CMS"

Is this a common problem is there a simple fix for it?

Avatar
JMagnusson

Community Member, 29 Posts

3 June 2011 at 4:48am

Edited: 03/06/2011 4:53am

I have the same problem. Have you find an answere?

My code:
<?php
/**
* Defines the SideBarPage page type
*/

class SideBarPage extends Page {
   
   static $icon = "images/treeicons/sidebar";
   
   static $db = array(
);

static $has_one = array(
'Photo1' => 'Image',
);
   
function getCMSFields() {
$fields = parent::getCMSFields();
   
    $fields->removeByName('RightSide');
    $fields->removeByName('BannerImage');
    $fields->removefieldFromTab("Root.Content.Main","Content");
    $fields->removefieldFromTab("Root.Content.Main","SideBarPage");
   
    $fields->addFieldToTab( 'Root.Content.Images', new ImageField('Photo1') );

    return $fields;
}

static $defaults = array(
    'ShowInMenus' => false ,
    'ShowInSearch' => false
);
}

class SideBarPage_Controller extends Page_Controller {

}
?>

And the result: "Sorry, there was a problem with handling your request."

/Johan