10376 Posts in 2191 Topics by 1708 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1321 Views |
-
Extending Newsletter.php to enable extra fields and a $has_one('Image')

29 September 2009 at 2:52pm
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
-
Re: Extending Newsletter.php to enable extra fields and a $has_one('Image')

29 September 2009 at 10:39pm
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.
| 1321 Views | ||
|
Page:
1
|
Go to Top |


