Page 2 of 2 FirstFirst 12
Results 11 to 19 of 19
  1. #11
    Join Date
    Jun 2007
    Posts
    24
    Plugin Contributions
    0

    Default Re: adding new templates to newsletter module

    Quote Originally Posted by DrByte View Post
    That dropdown determines which module to run from the modules/newsletters folder.
    If you want to add something to that dropdown and write a new module to go with it, feel free.
    if I just literally copied the newsletter.php file and changed the template name in there, would that work? Then I'd copy that file up to the server and it would appear in the drop-down. What I don't know if other functions would reference back to the newsletter.php file?

    Quote Originally Posted by DrByte View Post
    Sorry if that's too much tech talk -- you sounded like you had a handle on programming when you said you altered things to allow additional newsletter choices.
    It's not too much tech talk - I do have a handle on programming but are relatively new to zencart and have not delved in the email coding at all - mainlly dealt with the template side of things so far.

  2. #12
    Join Date
    Jan 2004
    Posts
    66,419
    Blog Entries
    7
    Plugin Contributions
    81

    Default Re: adding new templates to newsletter module

    Quote Originally Posted by christoph_lutz View Post
    i have amended the subscribe to newsletter option where users can tick different categories, so I can select those when sending a newsletter
    "How" are you selecting those when you send a newsletter?
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  3. #13
    Join Date
    Jun 2007
    Posts
    24
    Plugin Contributions
    0

    Default Re: adding new templates to newsletter module

    By selecting the audience from the dropdown. I have added queries to the query builder table that gets me the right group of customers

  4. #14
    Join Date
    Jan 2004
    Posts
    66,419
    Blog Entries
    7
    Plugin Contributions
    81

    Default Re: adding new templates to newsletter module

    Okay, then one approach could be to use the query_name value from the query-builder data (ie: the audiences list) to determine which template to use.

    1. Rename your special queries like this:
    Code:
    Subscriber Group: Bleeding Edge Racers
    or
    Subscriber Group: All Stars ~ Heavy Hitters
    2. Create corresponding email template files.
    The email templates for the example names above would be:
    Code:
    /email/email_template_bleedingedgerac.html
    /email/email_template_allstars.html
    Explanation:
    The template names will be built from the query_name (audience names) starting with 'Subscriber Group: ' followed by up to 15 chars for the template name (or until a ~ is found).
    Converted to lower-case letters to find the template filename.
    If a filename matching the pattern isn't found, the module name will be used instead.

    3. Make the following code edits to the admin/includes/newsletters/newsletter.php:
    Code:
        function send($newsletter_id) {
          global $db;
    
          // Look for audience names starting with 'Subscriber Group: ' and accept up to 15 chars for template name (takes name up to ~ or if no ~ then 15 max chars)
          $my_template_name = str_replace('Subscriber Group: ', '', $this->query_name);
          $my_template_name = preg_replace('/^[0-9a-zA-Z_~]/', '', $my_template_name);
          $pos = strpos($my_template_name, '~');
          $my_template_name = strtolower(substr($my_template_name, 0, ($pos > 0 && $pos < 15 ? $pos : 15) ));
    
          $audience_select = get_audience_sql_query($this->query_name, 'newsletters');
          $audience = $db->Execute($audience_select['query_string']);
          $records = $audience->RecordCount();
          if ($records==0) return 0;
          $i=0;
    
          while (!$audience->EOF) {
            $i++;
            $html_msg['EMAIL_FIRST_NAME'] = $audience->fields['customers_firstname'];
            $html_msg['EMAIL_LAST_NAME']  = $audience->fields['customers_lastname'];
            $html_msg['EMAIL_MESSAGE_HTML'] = $this->content_html;
            $html_msg['EMAIL_TEMPLATE_FILENAME'] = $my_template_name;
    This all requires that you implement the functions_email changes I mentioned earlier.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  5. #15
    Join Date
    Jun 2007
    Posts
    24
    Plugin Contributions
    0

    Default Re: adding new templates to newsletter module

    Hi Dr Byte,
    Nice one, this has worked - although your regular expression did not quite work as it cut off some of the name of the group and did not take out the spaces. I have just shortened it to [\s] so it's working fine now.

    Just one thing: Although I have now done it your way, I had thought I'd add a column to the table and put the template name in there. Would you think that's a bad idea?

    Thanks

    Christoph

  6. #16
    Join Date
    Jan 2004
    Posts
    66,419
    Blog Entries
    7
    Plugin Contributions
    81

    Default Re: adding new templates to newsletter module

    Feel free to do as you wish with it.
    I looked at the new-column-in-table approach and realized there'd need to be coding changes in several places in order to make that work, and I didn't want to risk breaking other things without thorough testing ... so I opted to give you the simplest route.

    Sorry about the bad regex ... I meant to go test that but forgot
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  7. #17
    Join Date
    Jun 2007
    Posts
    24
    Plugin Contributions
    0

    Default Re: adding new templates to newsletter module

    Hi,

    Fair enough, I just thought the extra column would be relatively simple but have not looked at the wider implications. In any case, I have got it working beautifully now which is great. I have also put in an alert in the result screen to show what template is being used so that other people who may be using it will see what's happening.

    Thanks for all you help on this one!

    And yes, regular expressions catch me out at times, too :) No worries

    Christoph

  8. #18
    Join Date
    Jul 2005
    Location
    Orlando, Fl
    Posts
    333
    Plugin Contributions
    0

    help question Re: adding new templates to newsletter module

    Dr Byte,

    I've done something similar here, where i've duplicated the newsletters module to create an additional one, let's call it "news2".

    I was able to use a different email template I created WITHOUT modifying functions_email.

    In the duplicated newsletter module... "news2" I changed the following at line 351:

    Code:
    <?php
      zen_set_time_limit(600);
      flush();
      $i = $module->send($nInfo->newsletters_id);
    ?>
    TO THIS

    Code:
    <?php
      zen_set_time_limit(600);
      flush();
      $current_page_base = 'news2';
      $i = $module->send($nInfo->newsletters_id);
    ?>
    I'm wondering if this is a bad way to accomplish this.

    Thanks

    DD

  9. #19
    Join Date
    Jan 2004
    Posts
    66,419
    Blog Entries
    7
    Plugin Contributions
    81

    Default Re: adding new templates to newsletter module

    I suppose if you only ever intend to send to one group, that's fine.
    The workaround to the original poster's question was way more generic than what you are suggesting, and doesn't require changing code everytime one wants to send a different newsletter.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

 

 
Page 2 of 2 FirstFirst 12

Similar Threads

  1. v151 Why my new templates installed doesn't appear in the templates selection?
    By dijah in forum Templates, Stylesheets, Page Layout
    Replies: 14
    Last Post: 14 Apr 2014, 11:08 AM
  2. Adding New Products to newsletter.
    By madmickc in forum General Questions
    Replies: 7
    Last Post: 9 Jun 2010, 04:14 AM
  3. Adding new variable in Email templates
    By erko in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 18 May 2010, 08:07 AM
  4. newsletter templates
    By wickedklown in forum General Questions
    Replies: 3
    Last Post: 1 Dec 2009, 09:19 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR