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.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Emailing image $Avatar


Reply

539 Views

Avatar
borriej

28 January 2012 at 12:52am (Last edited: 28 January 2012 12:53am), Community Member, 267 Posts

Hello,

I have memberprofiles in place with a registerform on the front-end. People can register and they get added to the Member table. I also have forum module installed, and therefor Member table is extended with a Avatar. People can upload an Avatar in the registration form. This all works, and you can view the avatar in your online profile or in the CMS (as admin).

After registration a few emails get send: 1 to Admin, 1 to user.

Ok now my issue:
in the emails i would like to include the avatar.. but how?

ive tried lots of things, like

<% control AvatarID %>
<img src="$SetWidth(150).Link" />
<% end_control %>
<% control Avatar %>
<img src="$SetWidth(150).Link" />
<% end_control %>
$AvatarID.SetWidth(150)
$Avatar.SetWidth(150)
$avatar.SetWidth(150)

      <img class="userAvatar" src="$FormattedAvatar" alt="Avatar" /><br />

but they all result in a broken path/link for the image source..

How do i include the avatar in the data that gets send?

my email function:

   function onBeforeWrite() {

if (!$this->owner->exists()) {

         /* ADMIN EMAIL ACTIVATE */
         $AdminEmail = new Email();
         $AdminData = $this->owner->getAllFields();
         $AdminToAddress = Email::getAdminEmail();
         $AdminEmail->setTo($AdminToAddress);
         $AdminEmail->setSubject('Nieuw lid: Activatie vereist');
         $AdminEmail->setFrom($this->owner->Email);
         $AdminEmail->setTemplate('EmailAccountActivation');
         $AdminEmail->populateTemplate($AdminData);
         $AdminEmail->send();
         
         /* USER EMAIL CONFIRMED CREATED */
         $UserEmail = new Email();
         $UserData = $this->owner->getAllFields();
         $UserEmail->setTo($this->owner->Email);
         $UserFromAddress = Email::getAdminEmail();
         $UserEmail->setSubject('Uw account is aangemaakt');
         $UserEmail->setFrom($UserFromAddress);
         $UserEmail->setTemplate('EmailAccountCreated');
         $UserEmail->populateTemplate($UserData);
         $UserEmail->send();
      
      
}
}