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   1560 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, 1799 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, 1799 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