MailPress Review – Theme Design (Styling)
Table of contents for MailPress Review
- MailPress Review – Introduction
- MailPress Review – Installation
- MailPress Review – Configuration
- MailPress Review – Selecting a Theme
- MailPress Review – Theme Design (Intro)
- MailPress Review – Theme Design (Styling)
Note (Feb. 12, 2008)
Andre has implemented a version of styling that I feel is superior to this one. I’ll provide an update at some point, but check out the MailPress2 style for details.
One of the limitations of MailPress themes is that you can’t use CSS. You can still use styles, but you have to specify them inline using the style=”" attribute. One of the things that CSS does for you is it gives you the ability to apply the same style across your templates without having to duplicate it every place you use it. To deal with this limitation, I thought, can’t I just define variables that contain the styles that can be referenced by all the templates just like a CSS style can?
The answer is yes – in functions.php.
I’ll show you how to do this by converting the MailPress theme. First let’s look at a simple template – daily.php. It looks like this:
<?php $this->get_header() ?>
<table style='margin:0;padding:0;border:none;width:100%;'>
<?php while (have_posts()) : the_post(); ?>
<tr>
<td style='margin:0;padding:0pt 0pt 20px 45px;border:none;width:450px;float:left;color:#333333;text-align:left;font-family:Verdana,Sans-Serif;'>
<div style='margin:0pt 0pt 40px;padding:0;border:none;text-align:justify;'>
<h2 style='margin:30px 0pt 0pt;padding:0;border:none;color:#333;font-size:1.4em;font-weight:bold;font-family:Verdana,Sans-Serif;'>
<a style='text-decoration:none;color:#333;' href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a>
</h2>
<small style='margin:0;padding:0;border:none;line-height:2em;color:#777;font-size:0.7em;font-family:Arial,Sans-Serif;'>
<?php the_time('F j, Y') ?>
</small>
<div style='margin:0;padding:0;border:none;'>
<p style='margin:0;padding:0;border:none;line-height:1.4em;font-size:0.85em;'>
<?php the_content(); ?>
</p>
</div>
</div>
</td>
</tr>
<?php endwhile; ?>
</table>
<?php $this->get_footer() ?>
Other templates (such as weekly.php and monthly.php) are very similar. Making a change is rather tedious as a result. Â What if we simple define those style strings as variables in functions.php? The result would look like this:
<?php $this->get_header() ?>
<table style='<?php echo $mptheme_style_outer_table; ?>'>
<?php while (have_posts()) : the_post(); ?>
<tr>
<td style='<?php echo $mptheme_style_title_td; ?>'>
<div style='<?php echo $mptheme_style_title_div; ?>'>
<h2 style='<?php echo $mptheme_style_title_h; ?>'>
<a style='<?php echo $mptheme_style_title_a; ?>' href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a>
</h2>
<small style='<?php echo $mptheme_style_small_date; ?>'>
<?php the_time('F j, Y') ?>
</small>
<div style='<?php echo $mptheme_style_content_div; ?>'>
<p style='<?php echo $mptheme_style_content_p; ?>'>
<?php the_content(); ?>
</p>
</div>
</div>
</td>
</tr>
<?php endwhile; ?>
</table>
<?php $this->get_footer() ?>
Here are the contents of function.php:
<?php $mptheme_style_font_family = 'font-family: Verdana, Sans-Serif;'; $mptheme_style_outer_table = 'margin: 0; padding: 0; border: none; width: 100%;'; $mptheme_style_small_date = $mptheme_style_font_family . 'margin: 0;' . 'padding: 0;' . 'border: none;' . 'line-height: 2em;' . 'color: #777;' . 'font-size: 0.7em;'; // Message title styles. $mptheme_style_title_td = $mptheme_style_font_family . 'margin: 0;' . 'padding: 0 0 20px 45px;' . 'border: none;' . 'width: 450px;' . 'float: left;' . 'color: #333333;' . 'text-align: left;'; $mptheme_style_title_div = 'margin: 0 0 40px;' . 'padding: 0;' . 'border: none;' . 'text-align: justify;'; $mptheme_style_title_h = $mptheme_style_font_family . 'margin: 30px 0 0 0;' . 'padding: 0;' . 'border: none;' . 'color: #333;' . 'font-size: 1.4em;' . 'font-weight: bold;'; $mptheme_style_title_a = 'text-decoration: none; color: #333;'; // Content styles. $mptheme_style_content_div = 'margin: 0; padding: 0; border: none;'; $mptheme_style_content_p = 'margin: 0;' . 'padding: 0;' . 'border: none;' . 'line-height: 1.4em;' . 'font-size: 0.85em;'; ?>
I believe this technique is important for maintaining themes. As I was developing a theme based on the MailPress theme I got tired of making the same modifications over and over again. Using this mechanism, I can make a change in one place (functions.php) and it will be applied consistently across all templates.
One caveat I found is that you can’t use definitions from functions.php in your header.php or footer.php files, which is a real shame.
A converted version of the themes I’ve converted can be found on my downloads page with some additional minor modifications.
Resources
MailPressThemeWithStyles.zip (59.9 KiB, 737 hits)




February 3rd, 2009 at 6:28 am
Thanks for this series, David.
I am in the process of installing MP, and found you while looking for some MP styling info as the MP documentation is limited.
Once I get MP working properly I will be looking at the above technique for styling a theme.
February 3rd, 2009 at 7:34 am
Thanks.
Note that the author of the plugin has come up with a similar but even better way to style. I haven’t had a chance to update this yet. He’s included his styled version with MailPress as the MailPress2 style.
February 18th, 2009 at 2:28 pm
Thanks for the review and details around your experience with the MailPress plug-in. I found it helpful. I’m testing the plug-in now for use as a replacement for Dada Mail which some of my users site editors have found confusing, in hopes that this plug-in will be easier.
I have had one feature that I can’t seem to determine whether it exists or not: I’d like to select a single category on my site that is “Newsletter” such that any post to that category then sends a message out to the subscribers. (I think that is possible.) However, I’d like that same category to show up on the site so that it can be used as an archive of the mailings. So far, when I try this, the category does not show up on the site.
See http://67.222.33.148/ and the newsletter link on the sidebar for the error:
ERROR # 0 !
Check you are using the appropriate link.
Incorrect link or already processed.
Any experience with this in your testing?
February 28th, 2009 at 7:36 pm
Great job David.
I wonder if anybody developed a Mailpress theme based on the Maginoo WordPress theme.
April 1st, 2009 at 4:32 am
Hi David.
Your download MailPressThemeWithStyles.zip http://dpotter.net/Technical/download/20/ does not work. may you mail me the file ?
John Myrstad
April 1st, 2009 at 8:48 am
Sorry about that. Should be fixed now. The URL is a little different, so be sure to click on the link in the article, not the one in your comment.
July 29th, 2009 at 7:36 am
I’m still new at wordpress and even so with the plugins. Do I understand it correctly that mailpress sends the post as a mail to all subscribed users as a kind of newsletter? This is the thing I’m looking for, so I’m hoping for it.
Regards,
Erwin
August 26th, 2009 at 8:35 am
David,
Thank heavens for these pieces you have posted about Mailpress. The documentation that comes with the Mailpress plugins and add-ons is very light.
Dan
October 7th, 2009 at 6:07 pm
Is there anyway to preview themes? Maybe as web pages? I’d really like to style mine up but it seems really tedious to make a change and have to go through the whole process of sending a test message just to check it.
As a test, I tried creating a page in WP based on a template with included to MP header.php, confirmed.php and footer.php but running in to trouble with variables and classes – “$this” specifically.
Any help with previewing pages in a theme?
Thanks,
Stace
January 28th, 2010 at 11:49 am
Hi!
I’m very fond of mailpress, but i have a little problem.
I would like to change font-size and most of all font-color on my Manage Subscription page. The page that shows up after e-mail confirmation.
Please help me…
/Johan
February 11th, 2010 at 7:30 am
Hi David
Can I just ask if you can help, I have wordpress site using magazeen theme, I would like this theme as MailPress theme for sending email, newsletter etc. Basically I tried to upload the whole magazeen theme files into MarilPress theme folder. It appeared in the MP theme lists and let me select it. But the email did not go out. Then I changed it to default theme, it worked. Would you please help in using magazeen theme with MP.
Thanks
K
February 14th, 2010 at 12:40 pm
Hi There,
I was excited to see this mod, but changes in functions.php don’t seem to have any effect on any of the templates.
Ilya