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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

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

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

Only show 6 records


Go to End


21 Posts   3091 Views

Avatar
copernican

Community Member, 189 Posts

2 February 2013 at 6:52am

Edited: 02/02/2013 7:45am

oops, forgot about SimpleImageField. So you'll see there are several lines of code that look like

$fields->addFieldToTab("Root.Content.Slides", new SimpleImageField('SlideImage1', 'Image')); 

you'll want to update those to use UploadField like so

$fields->addFieldToTab("Root.Content.Slides", new UploadField('SlideImage1', 'Image')); 

*Edit: updated SimpleUploadField to SimpleImageField.

Avatar
alex123

Community Member, 18 Posts

2 February 2013 at 7:00am

I already update But it shows the same problem.

Avatar
copernican

Community Member, 189 Posts

2 February 2013 at 7:46am

See my edited post, but to clarify.

Change any "SimpleImageField" and "SimpleUploadField" to "UploadField".

Avatar
alex123

Community Member, 18 Posts

2 February 2013 at 4:48pm

I change it like you ask me But It doesn't work

<?php

/**
* Defines the homePage page type
*/

class homePage extends SiteTree {
static $allowed_children = "none";

static $db = array(
'Address' => 'HTMLText',
'SlideDescriptionShort1' => 'Text',
'SlideDescriptionLong1' => 'Text',
'SlideDescriptionShort2' => 'Text',
'SlideDescriptionLong2' => 'Text',
'SlideDescriptionShort3' => 'Text',
'SlideDescriptionLong3' => 'Text',
'SlideDescriptionShort4' => 'Text',
'SlideDescriptionLong4' => 'Text',
'SlideDescriptionShort5' => 'Text',
'SlideDescriptionLong5' => 'Text',
'SlideDescriptionShort6' => 'Text',
'SlideDescriptionLong6' => 'Text',
'SlideDescriptionShort7' => 'Text',
'SlideDescriptionLong7' => 'Text',
'SlideDescriptionShort8' => 'Text',
'SlideDescriptionLong8' => 'Text',
'DomesticTitle' => 'Text',
'DomesticTagline' => 'Text',
'ProfessonialTitle' => 'Text',
'ProfessonialTagline' => 'Text',
'NewPanelTitle' => 'Text',
'NewPanelTagline' => 'Text',
'NewProductTitle' => 'Text',
'NewProductTagline' => 'Text',
'OurProductTitle' => 'Text',
'OurProductTagline' => 'Text',
'PublicationsTitle' => 'Text',
'PublicationsTagline' => 'Text',
);
static $has_many = array(
'UsedBy' => 'Sponsor'
);
public static $has_one = array(
'SlideImage1' => 'Image',
'SlideImage2' => 'Image',
'SlideImage3' => 'Image',
'SlideImage4' => 'Image',
'SlideImage5' => 'Image',
'SlideImage6' => 'Image',
'SlideImage7' => 'Image',
'SlideImage8' => 'Image',
'SlidePage1' => 'SiteTree',
'SlidePage2' => 'SiteTree',
'SlidePage3' => 'SiteTree',
'SlidePage4' => 'SiteTree',
'SlidePage5' => 'SiteTree',
'SlidePage6' => 'SiteTree',
'SlidePage7' => 'SiteTree',
'SlidePage8' => 'SiteTree',
'DomesticLink' => 'SiteTree',
'DomesticImage' => 'Image',
'ProfessonialLink' => 'SiteTree',
'ProfessonialImage' => 'Image',
'NewPanelLink' => 'SiteTree',
'NewPanelImage' => 'Image',
'NewProductLink' => 'SiteTree',
'NewProductImage' => 'Image',
'OurProductLink' => 'SiteTree',
'OurProductImage' => 'Image',
'PublicationsLink' => 'SiteTree',
'PublicationsImage' => 'Image',
);

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

// add field to edit footer and address section

$fields->addFieldToTab("Root.Content.Address", new HTMLEditorField('Address', 'Address'));

// Slides
// Slide 1
$fields->addFieldToTab('Root.Content.Slides', new LiteralField ($name = "literalfield", $content = "<h2>Left Slide Window</h2>"));
$fields->addFieldToTab('Root.Content.Slides', new LiteralField ($name = "literalfield", $content = "<h4>Slide 1</h4>"));
$fields->addFieldToTab('Root.Content.Slides', new TextField('SlideDescriptionShort1', 'Short description'));
$fields->addFieldToTab('Root.Content.Slides', new TextField('SlideDescriptionLong1', 'Long description'));
$fields->addFieldToTab('Root.Content.Slides', new TreeDropdownField('SlidePage1ID', 'Page', 'SiteTree'));
$fields->addFieldToTab("Root.Content.Slides", new UploadField('SlideImage1', 'Image'));
// $fields->addFieldToTab("Root.Content.Slides", new UploadField('Image', 'Image'));
//$fields->addFieldToTab("Root.Content.Slides", new UploadField('Image', 'Image'));
// Slide 2
$fields->addFieldToTab('Root.Content.Slides', new LiteralField ($name = "literalfield", $content = "<h4 style=\"margin:10px 0 0;\">Slide 2</h4>"));
$fields->addFieldToTab('Root.Content.Slides', new TextField('SlideDescriptionShort2', 'Short description'));
$fields->addFieldToTab('Root.Content.Slides', new TextField('SlideDescriptionLong2', 'Long description'));
$fields->addFieldToTab('Root.Content.Slides', new TreeDropdownField('SlidePage2ID', 'Page', 'SiteTree'));
$fields->addFieldToTab("Root.Content.Slides", new UploadField('SlideImage2', 'Image'));
// Slide 3
$fields->addFieldToTab('Root.Content.Slides', new LiteralField ($name = "literalfield", $content = "<h4 style=\"margin:10px 0 0;\">Slide 3</h4>"));
$fields->addFieldToTab('Root.Content.Slides', new TextField('SlideDescriptionShort3', 'Short description'));
$fields->addFieldToTab('Root.Content.Slides', new TextField('SlideDescriptionLong3', 'Long description'));
$fields->addFieldToTab('Root.Content.Slides', new TreeDropdownField('SlidePage3ID', 'Page', 'SiteTree'));
$fields->addFieldToTab("Root.Content.Slides", new UploadField('SlideImage3', 'Image'));
// Slide 4
$fields->addFieldToTab('Root.Content.Slides', new LiteralField ($name = "literalfield", $content = "<h4 style=\"margin:10px 0 0;\">Slide 4</h4>"));
$fields->addFieldToTab('Root.Content.Slides', new TextField('SlideDescriptionShort4', 'Short description'));
$fields->addFieldToTab('Root.Content.Slides', new TextField('SlideDescriptionLong4', 'Long description'));
$fields->addFieldToTab('Root.Content.Slides', new TreeDropdownField('SlidePage4ID', 'Page', 'SiteTree'));
$fields->addFieldToTab("Root.Content.Slides", new UploadField('SlideImage4', 'Image'));

$fields->addFieldToTab('Root.Content.Slides', new LiteralField ($name = "literalfield", $content = "<h2>Right Slide Window</h2>"));
// Slide 5
$fields->addFieldToTab('Root.Content.Slides', new LiteralField ($name = "literalfield", $content = "<h4>Slide 1</h4>"));
$fields->addFieldToTab('Root.Content.Slides', new TextField('SlideDescriptionShort5', 'Short description'));
$fields->addFieldToTab('Root.Content.Slides', new TextField('SlideDescriptionLong5', 'Long description'));
$fields->addFieldToTab('Root.Content.Slides', new TreeDropdownField('SlidePage5ID', 'Page', 'SiteTree'));
$fields->addFieldToTab("Root.Content.Slides", new UploadField('SlideImage5', 'Image'));
// Slide 6
$fields->addFieldToTab('Root.Content.Slides', new LiteralField ($name = "literalfield", $content = "<h4 style=\"margin:10px 0 0;\">Slide 2</h4>"));
$fields->addFieldToTab('Root.Content.Slides', new TextField('SlideDescriptionShort6', 'Short description'));
$fields->addFieldToTab('Root.Content.Slides', new TextField('SlideDescriptionLong6', 'Long description'));
$fields->addFieldToTab('Root.Content.Slides', new TreeDropdownField('SlidePage6ID', 'Page', 'SiteTree'));
$fields->addFieldToTab("Root.Content.Slides", new UploadField('SlideImage6', 'Image'));

// Slide 7
$fields->addFieldToTab('Root.Content.Slides', new LiteralField ($name = "literalfield", $content = "<h4 style=\"margin:10px 0 0;\">Slide 3</h4>"));
$fields->addFieldToTab('Root.Content.Slides', new TextField('SlideDescriptionShort7', 'Short description'));
$fields->addFieldToTab('Root.Content.Slides', new TextField('SlideDescriptionLong7', 'Long description'));
$fields->addFieldToTab('Root.Content.Slides', new TreeDropdownField('SlidePage7ID', 'Page', 'SiteTree'));
$fields->addFieldToTab("Root.Content.Slides", new UploadField('SlideImage7', 'Image'));

// Slide 8
$fields->addFieldToTab('Root.Content.Slides', new LiteralField ($name = "literalfield", $content = "<h4 style=\"margin:10px 0 0;\">Slide 4</h4>"));
$fields->addFieldToTab('Root.Content.Slides', new TextField('SlideDescriptionShort8', 'Short description'));
$fields->addFieldToTab('Root.Content.Slides', new TextField('SlideDescriptionLong8', 'Long description'));
$fields->addFieldToTab('Root.Content.Slides', new TreeDropdownField('SlidePage8ID', 'Page', 'SiteTree'));
$fields->addFieldToTab("Root.Content.Slides", new UploadField('SlideImage8', 'Image'));

$tablefield = new HasManyComplexTableField(
$this,
'UsedBy',
'Sponsor',
array( 'Thumbnail' => 'Image', 'CompanyName' => 'Company Name'),
'getCMSFields_forPopup'
);
$tablefield->setAddTitle( 'A Product User' );

// $fields->addFieldToTab( 'Root.Content.ProductUser', $tablefield );

$fields->addFieldToTab('Root.Content.NewsletterPanels', new LiteralField ("literalfield", "<h3>Domestic Newsletter Panel</h3>"));
$fields->addFieldToTab('Root.Content.NewsletterPanels', new TextField('DomesticTitle', 'Domestic Title'));
$fields->addFieldToTab('Root.Content.NewsletterPanels', new TextField('DomesticTagline', 'Domestic Tagline'));
$fields->addFieldToTab('Root.Content.NewsletterPanels', new TreeDropdownField('DomesticLinkID', 'Domestic Link', 'SiteTree'));
$fields->addFieldToTab("Root.Content.NewsletterPanels", new UploadField('DomesticImage', 'Domestic Image'));

$fields->addFieldToTab('Root.Content.NewsletterPanels', new LiteralField ("literalfield", "<h3>Professional Newsletter Panel</h3>"));
$fields->addFieldToTab('Root.Content.NewsletterPanels', new TextField('ProfessonialTitle', 'Professional Title'));
$fields->addFieldToTab('Root.Content.NewsletterPanels', new TextField('ProfessonialTagline', 'Professional Tagline'));
$fields->addFieldToTab('Root.Content.NewsletterPanels', new TreeDropdownField('ProfessonialLinkID', 'Professional Link', 'SiteTree'));
$fields->addFieldToTab("Root.Content.NewsletterPanels", new UploadField('ProfessonialImage', 'Professional Image'));

$fields->addFieldToTab('Root.ProductsPanels', new LiteralField ("literalfield", "<h3>New Newsletter Panel</h3>"));
$fields->addFieldToTab('Root.ProductsPanels', new TextField('NewPanelTitle', 'New Panel Title'));
$fields->addFieldToTab('Root.ProductsPanels', new TextField('NewPanelTagline', 'New Panel Tagline'));
$fields->addFieldToTab('Root.ProductsPanels', new TreeDropdownField('NewPanelLinkID', 'New Panel Link', 'SiteTree'));
$fields->addFieldToTab("Root.ProductsPanels", new UploadField('NewPanelImage', 'New Panel Image'));

$fields->addFieldToTab('Root.ProductsPanels', new LiteralField ("literalfield", "<h3>New Product Panel</h3>"));
$fields->addFieldToTab('Root.ProductsPanels', new TextField('NewProductTitle', 'New Product Title'));
$fields->addFieldToTab('Root.ProductsPanels', new TextField('NewProductTagline', 'New Product Tagline'));
$fields->addFieldToTab('Root.ProductsPanels', new TreeDropdownField('NewProductLinkID', 'New Product Link', 'SiteTree'));
$fields->addFieldToTab("Root.ProductsPanels", new UploadField('NewProductImage', 'New Product Image'));

$fields->addFieldToTab('Root.ProductsPanels', new LiteralField ("literalfield", "<h3>Our Products Panel</h3>"));
$fields->addFieldToTab('Root.ProductsPanels', new TextField('OurProductTitle', 'Our Product Title'));
$fields->addFieldToTab('Root.ProductsPanels', new TextField('OurProductTagline', 'Our Product Tagline'));
$fields->addFieldToTab('Root.ProductsPanels', new TreeDropdownField('OurProductLinkID', 'Our Product Link', 'SiteTree'));
$fields->addFieldToTab("Root.ProductsPanels", new UploadField('OurProductImage', 'Our Product Image'));

$fields->addFieldToTab('Root.Content.PublicationsPanel', new LiteralField ("literalfield", "<h3>Publications Panel</h3>"));
$fields->addFieldToTab('Root.Content.PublicationsPanel', new TextField('PublicationsTitle', 'Publications Title'));
$fields->addFieldToTab('Root.Content.PublicationsPanel', new TextField('PublicationsTagline', 'Publications Tagline'));
$fields->addFieldToTab('Root.Content.PublicationsPanel', new TreeDropdownField('PublicationsLinkID', 'Publications Link', 'SiteTree'));
$fields->addFieldToTab("Root.Content.PublicationsPanel", new UploadField('PublicationsImage', 'Publications Image'));

return $fields;

}
function LeftFeatureImage($width=30, $height=30) {
$Image = $this->SlideImage1();
if ( $Image ) {
if($Image->getWidth() > $width) {
return $Image->CroppedImage($width, $height);
} else {
return $Image;
}
} else {
return null;
}
}
function RightFeatureImage($width=30, $height=30) {
$Image = $this->SlideImage5();
if ( $Image ) {
if($Image->getWidth() > $width) {
return $Image->CroppedImage($width, $height);
} else {
return $Image;
}
} else {
return null;
}
}
function LightBox()
{
if (isset($_COOKIE['Lightbox']))
$cookie = 'none';
else
$cookie = 'block';

return $cookie;
}
}

class homePage_Controller extends Page_Controller {
// Latest News
function LatestNews($num=3) {
$news = DataObject::get_one("NewsPageHolder");
return ($news) ? DataObject::get("NewsPage", "ParentID = $news->ID", "Date DESC", "", $num) : false;
}

// Latest Events
function ComingEvents($num=3) {
$event = DataObject::get_one("EventPageHolder");
$yesterday = date('Y-m-d',mktime(0,0,0,date('m'), date('d')-1, date('Y')));
return ($event) ? DataObject::get("EventPage", "`ParentID` = '".$event->ID."' and Date > '{$yesterday}'", "Date DESC", "", $num) : false;
}

}

?>

Avatar
alex123

Community Member, 18 Posts

4 February 2013 at 4:04pm

Hi IOTI,

Did you check my issue ? I already change all "SimpleImageField" and "SimpleUploadField" to "UploadField" on mysite/homepage.php

Go to Top