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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Archive /

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

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

Extending member fields

Go to End

2 Posts   1919 Views


Community Member, 23 Posts

17 June 2008 at 12:57am

Edited: 17/06/2008 12:58am

Hey There,

I managed to extend the members with an extra class (db table).

  // define the db-fields
   static $db = array('Adres'  => 'Varchar',		
   					   'Postcode'  => 'Varchar',		
   					   'Woonplaats'  => 'Varchar',		
   					   'Telefoon'  => 'Varchar',		
   					   'Mobiel'  => 'Varchar',		
   					   'Geslacht'  => 'Varchar',		
   					   'Geboortedatum'  => 'Date'
   // Every profile has one member and one photo
   static $has_one = array(
		'Foto' => 'Image'

When i public view the profile i get all field by a $oMember = Member::get_by_id('Member',2);

I also get a Field called FotoID. But how can i view that image?

I tried :

<% control Foto %>
			Foto id = $ID
			<% control CroppedImage(103,105) %>
				<img id="profielImage"alt="<% control Member %>$FirstName $Surname<% end_control %>" title="<% control Member %>$FirstName $Surname<% end_control %>"src="$URL" />
			<% end_control %>
		<% end_control %>

But it doesn't render the image.

Please help :)



Forum Moderator, 5523 Posts

17 June 2008 at 10:53am

This is a annoying little thing ive noticed but you get a ID returned so what you need to do is add another method to use that ID to get the photo and return the file.

so you would need a method like

function FotoFile() {
return ($this->FotoID) ? DataObject::get_by_id("File", $this->FotoID) : false;

Then instead of using $Foto in the Template you would use $FotoFile for the Control.