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.

Archive /

Our old forums are still available as a read-only archive.

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

Setting Up Additional Images to a Page


Go to End


3 Posts   1671 Views

Avatar
brandstudio

Community Member, 5 Posts

2 May 2008 at 2:06pm

Hi Guys,

Can I say first silverstripe rocks, what an awesome piece of software to work
with!! Totally blown away.

OK MY PROBLEM

One of programmers set this site up sometime ago and can't remember what
he did - It may be an additional modification he has installed ( gallery maybe )

Anyways it works fine but currently it only allows you to add two images
to a "project" page. I need to make this a total of 5 images.
These images are different to the ones you can add via the main editor
and are displayed to the left of the page content not within the $content.

These are out putted like..

$Photo1.SetWidth(150)
$Photo2.SetWidth(150)

If this gives any clues as to the modification he may have added.

So what I need to DO....

SEE ATTACHED IMAGE FOR REFERENCE

FIG 2, shows the backend - I need to make this 5 images boxes instead
of only two it currently lets you add.

FIG 1, I then want to add another 3 images Im guess I do that simply
$Photo1.SetWidth(150)
$Photo2.SetWidth(150)
$Photo3.SetWidth(150)
$Photo4.SetWidth(150)
$Photo5.SetWidth(150)

Many Thanks for your help in advance.

P.S also any suggestions or built in function to make the fullsize image popup
if click from the front end?.. this isnt a major tho.

Sefton

Brandstudio

Avatar
brandstudio

Community Member, 5 Posts

2 May 2008 at 5:31pm

OK I found the solution myself and added this below.

I HAD TO ADD THE ADDITIONAL 3 PHOTOS TO THE BELOW ARRAY "projectpage.php" type page not holder.

static $has_one = array(
'Photo1' => 'Image',
'Photo2' => 'Image',
'Photo3' => 'Image', <-- HERE
'Photo4' => 'Image', <-- HERE
'Photo5' => 'Image' <-- HERE
);
function getCMSFields() {
$fields = parent::getCMSFields();

THEN ALSO ADD ANOTHER 3 ROWS HERE

$fields->addFieldToTab('Root.Content.Main', new CalendarDateField('Date'), 'Content');
$fields->addFieldToTab('Root.Content.Main', new TextField('Author'), 'Content');
$fields->addFieldToTab("Root.Content.Images", new ImageField('Photo1'));
$fields->addFieldToTab("Root.Content.Images", new ImageField('Photo2'));
$fields->addFieldToTab("Root.Content.Images", new ImageField('Photo3')); <-- HERE
$fields->addFieldToTab("Root.Content.Images", new ImageField('Photo4')); <-- HERE
$fields->addFieldToTab("Root.Content.Images", new ImageField('Photo5')); <-- HERE

return $fields;
}
}

Avatar
Sean

Forum Moderator, 922 Posts

2 May 2008 at 5:47pm

That would work. Don't forget to run db/build?flush=1