Jump to:

10979 Posts in 2722 Topics by 1815 members

All other Modules

SilverStripe Forums » All other Modules » Extending newsletter with image etc...

Discuss all other Modules here.

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

Page: 1
Go to End
Author Topic: 789 Views
  • Thomashv
    Community Member
    32 Posts

    Extending newsletter with image etc... Link to this post

    I really have problems with extending the newsletter module with some pictures and a newsbox. When making sites for people that are not very concius about how they place and scale elements in wysiwig editors I need adapt the newsletter module some more. The goal is that the template could be more spesific so that elements are displaying at same places and having the same shapes and sizes for every newsletter. There is a some posts on this in the forum, but they are pretty old and don't seem to be solved. So I hope this can be a complete post that will be solved soon with a little help from you.

    I have started to extend the newsletter with the object decorator like this:

    in mysite/code/MyNewsletter.php

    class MyNewsletter extends DataObjectDecorator {
    public function extraStatics() {
    return array(
    'has_one' => array(
    'NewsletterImage' => 'Image'

    public function updateCMSFields(FieldSet $fields) {
    new ImageField('NewsletterImage', 'Bilde') // doesn't work

    in mysite/config.php:

    Object::add_extension('Newsletter', 'MyNewsletter');

    I have also tried DataObject::add_extension('Newsletter', 'MyNewsletter');
    Not quite sure what the differents would be.

    In the newsletter/code/NewsletterEmailProcess.php in the function called next i have added folowing to line 88 (marked in red):

                      'Member' => $member,
                      'FirstName' => $member->FirstName,
                      'NameForEmail'=> $nameForEmail,
                      'NewsletterImage' => $this->newsletter->NewsletterImage

    The ImageField is called, but I get this error inside the feild iframe:

    Unknown Email ID: 0
    Line 548 in /home/ua00002/subdomains/demo/newsletter/code/NewsletterAdmin.php


    539          if($email->Status != 'Draft') {
    540             $readonlyFields = $form->Fields()->makeReadonly();
    541             $form->setFields($readonlyFields);
    542          }
    544          // user_error( $form->FormAction(), E_USER_ERROR );
    546          return $form;
    547       } else {
    548          user_error( 'Unknown Email ID: ' . $myId, E_USER_ERROR );
    549       }
    550    }
    552    public function SendProgressBar() {
    553       $progressBar = new ProgressBar( 'SendProgressBar', _t('NewsletterAdmin.SENDING','Sending emails...') );
    554       return $progressBar->FieldHolder();

    Some how the image upload field needs to get the Email ID. Is there anybody who knows how i may parser that ID to the ImageField?

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.