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.

Customising the CMS /

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

creating new imagefield for content


Go to End


5 Posts   2029 Views

Avatar
bunheng

Community Member, 78 Posts

2 November 2010 at 10:09am

Hi,

I would like to know is there any possible way to create additional imagefield for content, because my website will have different photo for each page. Please kindly have a look at my testing website http://www.cambodia-wildlife-adventures.org/ you will see each page have the same photo display.

Bunheng

Avatar
swaiba

Forum Moderator, 1899 Posts

2 November 2010 at 10:19am

All covered in here...

http://doc.silverstripe.org/tutorial:2-extending-a-basic-site

but instead of static $db = array('Date'... you want $has_one = array('MyImage' => 'Image');

and instead of TextField or DateField you want... ImageField...

Avatar
bunheng

Community Member, 78 Posts

2 November 2010 at 11:44pm

Hi,

Thanks for your replies, now it works fine on my website, additional thing is, is it possible that we can write any condition to check if there is no image on that imagefield then we need to display other thing?

Thanks for your help.

Bunheng

Avatar
swaiba

Forum Moderator, 1899 Posts

3 November 2010 at 1:06am

sure... somethign like...

<% if MyImageID != 0 %>
   $MyImage
<% else %>
  No Image
<% end_if %>

Avatar
bunheng

Community Member, 78 Posts

3 November 2010 at 4:06pm

Thanks, I work now, with following code:

<% if MyImageID %>
$MyImage
<% else %>
No Image
<% end_if %>

Thanks