In this post we're going to go over how to get the MailChimp snippet set up and working on your MODx Evolution site. MailChimp is a service that allows you to send email newsletters, manage subscriber lists, and track campaign performance. You can of course simply create the forms and such directly in MailChimp and paste the supplied code into your site, but this little snippet works just great. The directions I will outline here are also covered in the documentation inside the snippet folder, but I thought I would go over it for my own future reference and for anyone who may not be aware that this snippet exists or who may have had trouble setting it up. I am using MODx Evolution 1.0.2 and will be setting this demo up on the Learn MODx website.
Part 0: Introduction Part 1: Write and Test the PHP Script Part 2: Create the Snippet So far we have created the raw PHP script and tested the code outside of MODx. We've started the process of transforming this script into the rssfeedFetcher snippet and we have it working on the Learn MODx website. We've learned how to add optional parameters with default values to our call and everything seems to be working as expected. At the close of the last segment, I mentioned that our snippet is still relatively inflexible because the user has no control over how the output looks. We're going to rectify this today by tapping a little into the MODx API to create placeholders and utilize chunks to allow for some templating and customization of the output.
Part 0: Introduction Part 1: Write and Test the PHP Script In the last installment of this brief series we went through the process of creating the raw PHP script that will form the basis of our snippet. We tested the code outside of MODx and it seemed to work pretty well. In this part, we're going to start the process of transforming this script into a MODx snippet. As I said before, I will be working on the Learn MODx website that we built during the MODx Beginner series of tutorials. My goal is to use the snippet to add one or maybe two sections of MODx related feeds to the sidebar of the website. But first, we need to create the snippet itself, so let's get to work :)
Part 0: Introduction In the introductory post, I explained briefly what we're going to create, made some important disclaimers, and blew some hot air around. In this part, we're going to get our hands dirty by diving in and writing the PHP script and testing it outside of MODx to make sure it works. In general, I think this is a good idea because it allows you to iron out any purely PHP issues in your code before dealing with the MODx side of things. Chances are that even after you've tested it and ported it into MODx, you'll end up adding more PHP logic and stuff but if you can test most of it outside MODx first, it should potentially save you some headaches and debugging time when working inside MODx. This is especially important because once inside the MODx editor there's no syntax highlighting, automatic indenting and all that other good stuff. With that in mind, let's go ahead and create our script.
Welcome to this new series of tutorials on the MODx CMS where we're going to be talking about creating custom snippets for MODx Evolution 1.0.x. We've been building a website called Learn MODx and so far it's just a simple but functional website. We're going to keep building on and enhancing this website. Before we proceed, I should mention that I've already updated the Learn MODx website to the most recent version of MODx Evolution 1.0.2. If you started at the beginning with me and still have your site running on 0.9.6.3, please take a moment to upgrade your site. You can watch this screencast on how to upgrade your MODx site. In this series on creating simple custom snippets, we're going to look at the basics of creating your own snippets. I'm no PHP guru so we're not going to be doing anything crazy here :) but I hope to give you enough information to jump start you into exploring and digging further to create bigger and better things and see how truly powerful and extensible MODx is. At this point I assume you know what a snippet is and have probably already used some snippets in your own MODx websites. (If you don't know what a snippet is, please go over the MODx Beginner Series as that will help lay the foundation for this series).