Jump to:

17452 Posts in 4473 Topics by 1971 members


SilverStripe Forums » Archive » Extending member fields

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

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

Page: 1
Go to End
Author Topic: 1577 Views
  • Mednezz
    Community Member
    23 Posts

    Extending member fields Link to this post

    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


  • Willr
    Forum Moderator
    5511 Posts

    Re: Extending member fields Link to this post

    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.

Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.