MODX

Type
Wed Jul

Periodic Table of DevOps

The DevOps landscape is quite expansive. The depth and breadth of tooling available to us as companies is baffling…. All of this is compounded by the fact that many tools…

The DevOps landscape is quite expansive. The depth and breadth of tooling available to us as companies is baffling…. All of this is compounded by the fact that many tools overlap in their capabilities and are perpetually shrinking or expanding their offerings on a daily basis.

View
Type
Tue Dec

MODx Marketo Integration for the XebiaLabs Website

XebiaLabs uses MODx for its content management system and Marketo for its marketing automation system. To integrate Marketo into MODx I came up with an extremely creative solution that used…

modx-and-marketo

XebiaLabs uses MODx for its content management system and Marketo for its marketing automation system. To integrate Marketo into MODx I came up with an extremely creative solution that used a custom PHP class to pull Marketo lead data from their SOAP API and then subsequently populate that data into corresponding MODx “placeholder” elements.

First I found a php client for pulling the information from Marketo’s SOAP API, they provide some code here to pull lead data, but I wanted something I could use to pull other information from their API. turns out, someone had already done much of the heavy lifting.

I then coded the below snippet that does the following.

Initially I check to see if I’m specifying a lead manually by passing someone’s email in a query parameter. This is a nice override for when I need to view pages as a specific person within our database. It’s also nice when I need to ensure that someone sees a webpage with their info. I can append the link I have in an email, for example, to include their email, and subsequently ensure they see they website as they should. They may not have a munchkin cookie after all.  If I view a user in this method I store the information in a session so that I don’t have to perpetually communicate with the Marketo API for future pageviews.

If I then view any subsequent page on the website my information gets pulled from the session.

If I don’t have a query parameter specified for a user, and I don’t have any sessions from a previous website visit I use the PHP client to see if their is a munchkin cookie in the user’s browser.

If their is I pull the viewers lead data using their munchkin cookie. Then, as with the query parameter example I store the user’s info in a session variable so that I don’t have to communicate with the API again.

After lead data is stored in a session or pulled directly from the Marketo API I am then able to pass the information to a built in MODx method for displaying information. I use something they call “Placeholders”.

Learn more about placeholders here.

Check out the code here:

This code is lacking some serious security precautions and error handling. It is being worked on for the future, and I will try to update. Please comment if you would like further direction.

View
Type
Sun Oct

Change MODx Resources to Cacheable In Bulk

Whenever I edit a MODx page I usually find myself making it uncacheable so that I can temporarily make quick updates and see the page in its new form upon…

Whenever I edit a MODx page I usually find myself making it uncacheable so that I can temporarily make quick updates and see the page in its new form upon each refresh. The problem is that I sometimes forget to make the page cacheable again when I’m done editing.

If you are careless like me then the following snippet might be useful for changing your MODx resources to cacheable in bulk. To do this simply specify the ultimate parent of the resources you would like to cache, the depth to go when collecting the resources to cache, and the sort order.

View
Type
Wed Oct

How to Remove “Duplicate Of” and “duplicate-of” in MODX

Modx does this thing when you duplicate a resource. It will automatically add “Duplicate Of” to the page title and “duplicate-of” to the alias. In theory this should be very…

Modx does this thing when you duplicate a resource. It will automatically add “Duplicate Of” to the page title and “duplicate-of” to the alias. In theory this should be very helpful because it:

  • Differentiates between the old resource and the new resource
  • Highlights it as something that needs to be changed in the resource tree
  • Differentiates the resource by its alias so that two resources aren’t sharing the same URL

However, this past day I found myself mass duplicating parent folders full of resources (for one reason or another), and I only really needed to change the title of the top level parent resource to get the children to work correctly in the context of the project.

I imagine this is an edgecase, but I’m also sure that there are people out there doing the same thing.

In this circumstance it becomes super annoying to go through and replace the “deuplicate-of” in the alias and the “Duplicate of” in the title. This is a nice little snippet that will help you achieve that.

View

Subscribe for More!


I send out a monthly newsletter on various topics.

Take a moment to enter your details, and you can select the news you would like to have delivered to your inbox!