I've created a derivative (read: bast*rdized) version of simplenews_template that lets you create "Newsletter template" nodes containing your template code instead of using .tpl files.

Reason for coding this: Wanted to be able to copy and paste template code for a HTML-based email directly into a drupal website and have the flexibility to use different newsletter templates for different issues of a particular newsletter.

To be honest I didn't really give the .tpl system much of a go before implementing this - so will be interested to see how it compares to the (much more mature) tpl approach.

Have attached the code to this email if you want to give it a test drive - it's really not ready for production sites so DON'T PUT THIS ON A PRODUCTION SITE! :P

You will need to patch the 6.x-2.x-dev version of simplenews (just a bit) to use this. I've included a copy of a prepatched version of simplenews to make life easier. Also, you will need to uninstall any existing copies of simplenews_template, remove your old modules/simplenews_template folder and install my modified simplenews_template folder into your modules folder instead.

  • Each "Newsletter template" node has a textarea for "HTML Template" and "Plaintext Template."
  • Once you create a "Newsletter template" you can edit a Newsletter and assign that template as the "default template" for a particular newsletter.
  • When you go to create a "Newsletter issue", when you select the newsletter from the drop down list, an ajax loader will give you a list of all the "Newsletter templates" you can use for that issue. (with the default for the newsletter preselected).
  • Once you have entered some content for the newsletter issue (in the textarea/body of the newsletter issue) you will need to click on "Save" to preview the newsletter.
  • Clicking on Edit, then sending a test email to your email address should give you a preview of the newsletter in your email client

It still needs work, and probably needs a few fixes for security reasons, but might be a good starting point for others looking for this sort of functionality.

Comments, questions and complaints can be directed to me (anodyne), this thread, or /dev/null. :D

Happy templating!

-anodyne

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

franz’s picture

But simplenews_template is not meant for working with tpl, that's why it provides textares for header, body and footer (and css). Am I pretty wrong or you're talking about Simplenews itself (it uses tpl files).

anodyne’s picture

Sorry franz,

You're right, I was referring to simplenews itself - simplenews_template gives you textareas for header, body and footer.
With this code I've uploaded I've simply added the ability to have more than one template associated with a newsletter.

* simplenews_template gives you the ability to change header/body/footer for each newsletter you have.
* simplenews_template only lets you have one header/body/footer per newsletter. ie. 1:1 relationship.
* my version of simplenews_template (still in development) lets you have multiple header/body/footers, each stored in separate nodes, that you can assign to as many newsletters as you like. ie. a newsletter now has a default template (header/body/footer) but when you send out a newsletter issue, you can send it out with the default template, or you can use another template (ie. for special editions of your newsletter where you may want a different style or layout).

will upload some screenshots shortly so the distinction is a bit more obvious.

cheers,

-anodyne.

franz’s picture

Sounds nice!

I can see we could branch the code to a 2.x version, what do you think?

Alas, have you posted the patch you mentioned to simplenews?

franz’s picture

Title: Modified version of simplenews_template without the .tpl files » simplenews_template with multiple templates per newsletter

Changing the title to better address the issue, is that ok?

anodyne’s picture

Yes, that's fine - thanks franz! :)

anodyne’s picture

Hi Franz,

Sorry I haven't posted my patch to simplenews yet - am still testing/improving my multi-template code so will probably submit a single patch rather than multiple patches for simplenews 2.x.

-anodyne.

Vi-2’s picture

Multiple templates per newsletter : that's exactly what I'm looking for !
I'm looking forward to the patch !
Great work !

danzsmith’s picture

Also looking forward to this - we really need this on our production site!

danzsmith’s picture

FYI I downloaded and installed the attached files. I know you say it is not ready but one thing that really stands out right now - when you go to the Create Newsletter node you cannot select a template - it is a small blank select box with nothing in it. I have set up a default template, etc but even that is not selectable.

Anyway I guess I will wait for the official patch but just wanted to bring this up.

Thanks...

kenorb’s picture

Status: Active » Closed (outdated)

Closed because Drupal 6 is no longer supported. If the issue verifiably applies to later versions, please reopen with details and update the version.