WordPress.org

Ready to get started?Download WordPress

Forums

ALO EasyMail Newsletter
Enabling PHP code on Newsletter themes (6 posts)

  1. eqhes
    Member
    Posted 2 years ago #

    Hi,

    First of all, thank you Alessandro Massasso for such great plugin ;).

    I'm using ALO EasyMail Newsletter 2.2.1. I need using custom fields to extend this plugin and I resolved it editing this 2 lines on alo-easymail_functions.php. With this hack you will be able to use PHP on your themes and, of course, you will be able to use custom fields.

    Replace this:
    >>>
    $html = file_get_contents( $theme_path );
    >>>

    By these others:
    >>>
    ob_start();
    require( $theme_path );
    $html = ob_get_clean();
    >>>

    And this other one:
    >>>
    $themes = glob( $dir. "*.{htm,html}", GLOB_BRACE );
    >>>

    By the next:
    >>>
    $themes = glob( $dir. "*.{htm,html,php}", GLOB_BRACE );
    >>>

    In the theme file you are going to need the folder URL of the theme, and we know that it's not the same if we are sending an email than if we are reading the newsletter online. Here is how I get it (put this code on the top of your theme main file):
    >>>
    <?php
    $newsletter_data_folder = "";
    if( empty( $theme ) ){ //$theme cames from alo-easymail_functions.php
    $newsletter_data_folder = get_bloginfo("template_url")."/alo-easymail-themes/your_newsletter_name";
    }else{
    $newsletter_data_folder = str_replace( ".php", "", $theme );
    }
    ?>
    >>>

    All done! :)

    http://wordpress.org/extend/plugins/alo-easymail/

  2. eventualo
    Member
    Plugin Author

    Posted 2 years ago #

    Hi eqhes! Thanks a lot for your code! I'll add it in next release.
    Well done!

  3. eqhes
    Member
    Posted 2 years ago #

    Great! Thank you ;).

  4. remo.sometimes
    Member
    Posted 2 years ago #

    I love this plugin!
    In version 2.3 is now possible to use PHP and I'm trying to use Custom Fields in my template.
    I try to get custom field in the loop and it works fine in my single-newsletter.php template, I use the same code in my template file, but when I send the mail the content is blank.
    What am I doing wrong?
    Thank you!

  5. eventualo
    Member
    Plugin Author

    Posted 2 years ago #

    I forgot to document it... but in php template file you can use 2 available objects: $newsletter, $recipient.
    The newsletter (post) ID is: $newsletter->ID.
    So you can call a newsletter/post meta:
    get_post_meta($newsletter->ID, 'meta_name', true);

  6. remo.sometimes
    Member
    Posted 2 years ago #

    Thank you, eventualo!

    It also worked for me coding my custom fields as placeholders in alo-easymail_custom-hooks.php:
    in custom_easymail_placeholders I define my [CUSTOM-FIELD-AS-PLACEHOLDER] and I get the custom fields values in custom_easymail_placeholders_get_latest in which I replace the placeholders with the values.

    However calling directly the get_post_meta($newsletter->ID, 'meta_name', in the newsletter template file I think is the smartest solution.

    Thank a lot!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic