We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 27106
    • 147 Posts
    Here’s the challenge: to take a normal MODx website post and transform it for use in an email despatch system.

    The typical website post contains a linked stylesheet plus paragraphs like this:
    <p>My paragraph.</p>


    But in email, we want our styling to be inline, like this:
    <p style="font-size: 10px; font-family: Verdana, Arial, Helvetica, sans-serif; margin: 0px; padding: 0px; color: #CCCCCC;text-align: left;">My paragraph.</p>


    What we want is some magic that says: take this page and create a new version of it, replacing all paragraph tags with extended paragraph tags containing inline styling. This will be the page we load into our email despatch system.

    (The alternative is to just write some sort of search-and-replace function in AutoHotKey or similar, and run the page through that each time. But that involves extra work.)

    Does anyone have any ideas on how to transform a MODX post this way?
      David Walker
      Principal, Shorewalker DMS
      Phone: 03 8899 7790
      Mobile: 0407 133 020
      • 33968
      • 863 Posts
      I don’t have any magic unfortunately, but to achieve this you’ll need to write a class (or use an existing one) which will convert your linked styles to inline css.
        • 27106
        • 147 Posts
        Just so you know, this issue has now been addressed as part of Bob Ray's EmailResource Plugin. Thanks to Lucas for pointing to Tijs Verkoyen's PHP CssToInlineStyles class, which ended up as part of EmailResource. Details are in Bob Ray's EmailResource Plugin tutorial at http://bobsguides.com/emailresource-plugin-tutorial.html.
          David Walker
          Principal, Shorewalker DMS
          Phone: 03 8899 7790
          Mobile: 0407 133 020