I'm trying to get my registered Members from the database and display them in the frontend.
I extended it using this class
<?php
class MyMember extends DataExtension {
static $db = array(
'Description' => 'Varchar(250)'
);
static $has_one = array(
'Image' => 'Image'
);
public function getCMSFields() {
$this->extend('updateCMSFields', $fields);
return $fields;
}
public function updateCMSFields(FieldList $fields) {
$fields->push($imageUpload = new UploadField('Image', 'Profile Image'));
$imageUpload->setFolderName('Profile');
return $fields;
}
}
So now my Members have a profile picture and a Description.
I am able to display the Members details and the image but SEPARATELY
because I don't really know how.
I'm not very familiar with Silverstripe and PHP
please help
this is the function I use to display them
for the picture
function getPicture(){
$avatar = File::get()->innerJoin("Member", "\"Rel\".\"ImageID\" = \"File\".\"ID\"", "REl");
return $avatar;
}
for the Members detail
function pullMembers(){
$members = DataObject::get('Member');
//$avatar = DataObject::get_by_id('Image', $members->ImageID);
//return $members;
return $members;
}
the templat
<div class="content-container">
<article>
<h1>$Title</h1>
<div class="content">
$Content
<% control getPicture %>
<img style="width: 50px" src="$filename"/>
<% end_control %>
<% control pullMembers %>
<ul>
<li><p><b>$Title</b></p></li>
<p>$Email</p>
<p>$Description<p>
</ul>
<% end_control %>
</div>
</article>
$Form
</div>
<% include SideBar %>
I would like to display their image together with the Members detail