Jump to content

Developer Documentation

core/BulkMail

What it does

The BulkMail extension allows you to define macros (replacement tags) available for use when a bulk mail is being created or edited. For example, your application may wish to allow tags to be used to insert certain statistics (number of records in the application) or certain member data (how many times a member has submitted to your application).

How it works

The extension defines two very simple methods. The first method is called to return an array of tags that are available.

    /** 
     * Get tags that can be used in bulk mail
     *
     * @return    array
     */
    public function getTags()
    {
        return array(
            '{some_tag}'    => 'Explanation of tag',
        );
    }

The second method performs the actual replacements. You would need to loop through the tags you support, and then return the appropriate replacement for the individual member being emailed.

    /** 
     * Get value for tags
     *
     * @param    string                $content    Bulk Mail Content (passed in case a particular tag is computationally expensive so that the extension may "sniff" for it and elect not to perform the computation if it is not used)
     * @param    int                    $type        0=All, 1=Global, 2=Member-specific
     * @param    NULL|\IPS\Member    $member        Member object if $type is 0 or 2
     * @return    array
     */
    public function returnTagValues( $content, $type, $member )
    {
        return array(
            '{some_tag}'    => 'Value',
        );
    }

The $content parameter is ONLY to be used to determine if fetching the replacement value is worthwhile. If, for instance, a resource intensive query must be ran to replace a specific tag however the tag was not used in the body of the email, you should skip running the intensive query since the value will not be needed. The $type parameter specifies whether all tags should be returned, global tags (i.e. tags which return the same value regardless of which member is being emailed) should be returned, or only per-member tags should be returned.

Finally, the member being emailed is passed to the method as $member.

The replacements will then be performed by the bulk mailer when bulk mailing the membership of the site.


  Report Document


×
×
  • Create New...