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

[solved] Adding Image upload to Features tab in basic CWP site


Go to End


3 Posts   728 Views

Avatar
Ohmann

Community Member, 3 Posts

18 November 2015 at 4:18pm

Hi there,

I have managed to add a 3rd Features dropdown field to the Features tab on the HomePage template without editing the BaseHomePage file. I tweaked the 3rd features dropdown field to include an image upload area. This is working great. However, I tried to add an Image field to the other two feature dropdown fields but I am not sure how to do that without editing the BaseHomePage file.

Avatar
camfindlay

Forum Moderator, 267 Posts

19 November 2015 at 3:38pm

Hi Ohmann,

So what I think you are doing here is altering the state of the CMS interface form, in the subclass of the BaseHomePage page type from the cwp/cwp module.

You could use the "addFieldToTab" method for each photo and make sure the third argument is set to something like each Feature Title.

For example, the CWP module BaseHomePage has a DB field called "FeatureOneTitle" so you could place images above this by using:

$fields->addFieldToTab('Root.Features', UploadField::create('FeatureOneImage'), 'FeatureOneTitle');

'FeaturedOneTitle' is the form field you want to put your new field ABOVE. So this could also be 'FeatureOneContent' if you wanted this above the content block instead.

So what you are doing here is taking what is generated in BaseHomePage then altering it in HomePage before it gets displayed out in the CMS.

Hope that makes sense.

Avatar
Ohmann

Community Member, 3 Posts

19 November 2015 at 3:53pm

Thank you very much Cam. This made sense and works perfectly.