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.

Customising the CMS

creating new imagefield for content


Reply

5 Posts   1537 Views

Avatar
bunheng

2 November 2010 at 10:09am Community Member, 78 Posts

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

2 November 2010 at 10:19am Forum Moderator, 1796 Posts

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

2 November 2010 at 11:44pm Community Member, 78 Posts

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

3 November 2010 at 1:06am Forum Moderator, 1796 Posts

sure... somethign like...

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

Avatar
bunheng

3 November 2010 at 4:06pm Community Member, 78 Posts

Thanks, I work now, with following code:

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

Thanks