Jump to:

10979 Posts in 2722 Topics by 1815 members

All other Modules

SilverStripe Forums » All other Modules » Extending Newsletter.php to enable extra fields and a $has_one('Image')

Discuss all other Modules here.

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

Page: 1
Go to End
Author Topic: 1443 Views
  • novaweb
    Avatar
    Community Member
    115 Posts

    Extending Newsletter.php to enable extra fields and a $has_one('Image') Link to this post

    Hey Hey SilverStrippers,

    We've been working on extending newsletter.php so we can add an image, link and one other textfield to the newsletter.

    We've successfully extended the $db array and likewise with the CMS fields, the problem is - when we call them from our template - they don't show.

    I'll just use the image as an example:

    Newsletter.php line 23

       static $has_one = array(
          "Parent" => "NewsletterType",
          "NewsletterImage" => "Image"
       );

    Newsletter.ss

    <div id="Newsletter">
    $Body

    $NewsletterImage

    </div>

    Is there something extra we need to do? ... Do we need to apply some code to "class Newsletter_Email extends Email " at the bottom of Newsletter.php?

    KThxBye

  • Pigeon
    Avatar
    Community Member
    243 Posts

    Re: Extending Newsletter.php to enable extra fields and a $has_one('Image') Link to this post

    Hey, Unfortunately i'm not a SilverStripper... But i will try to help

    Perhaps try defining a method in the Newsletter.php, eg:

    function NewsletterImage() {
    return DataObject::get_one('Image','ParentID = '.$this->ID);
    }

    (or to that effect) and then $NewsletterImage should work in the template... Although i know the Newsletter module isn't quite as easy to manipulate in this way.

    1443 Views
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.