Setting up an RSS Feed Parser in MODX

MODX uses an add-on called getFeed to parse RSS content.

In order to use it, place this code on your page template (example uses the Faculty News Feed):


The code pulls the RSSFeedParser, a custom chunk we made that pulls the most recent article title and link.

Titles are pulled using:


Links are pulled using:


Here is a list of other data fields that may be pulled from the RSS Feed, if available:

  • title – The title of the post.
  • link – A direct link to the post.
  • description – The description of the post.
  • pubdate – The date the post was published.
  • guid – The GUID of the post.
  • author – The name of the author of the post.
  • category – Any tags or category associations the post has.
  • summary – A short summary of the post.
  • date_timestamp – The timestamp of the post.

Like most MODx variables, wrap the data fields with double square brackets, but be sure to use the + sign prefix rather than the * symbol.

Full-Time Faculty Table

The Full Time Faculty Table implements one ditto that calls two separate chunks.

The chunks are:


The structure of both dittos are the same, with only the row background color being different using the existing even and odd classes within the main style sheet.

When calling the ditto, filter the results using:


This sorts the list based on Faculty Type.

When adding fields use the + sign instead of the usual *, so to add the professor’s title, it would look like this:


To integrate a link, use this format:

<a href="mailto:[[+email]]"">[[+email]] </a>

Trouble Viewing Published Material on MODx?

If you’re making an edit to an existing page that has been unpublished in the past, be sure to take an extra look at the “Hide Template Variables on Output” field.

The field is located under most page templates under Template Variables -> Templates – Default TVs:

It varies, but the field in most page templates can be found at the very bottom of the page:


A Template Variable or TV, is simply what MODx calls a custom field found in page creation forms. When this field is set to “Yes” and the page is published, no content will be viewable.

This field is set to “No” by default and should not be a problem when creating new content.



Events Planning Form Using Javascript

A short questionnaire to direct users to the right form using Javscript
window.onload = function() { document.getElementById('link1').style.display = 'none'; document.getElementById('link2').style.display = 'none'; }; //Clears div box

var x, y, z; //assigns variables to radio selections

function a1(answer1){ x = answer1; };
function a2(answer2){ y = answer2; };
function a3(answer3){ z = answer3; };

//if all answers are no, display link2 and hide link2; if any answers are yes, do the opposite.

function showdiv() { if (x==1 | y==1 | z==1){ document.getElementById('link1').style.display='block'; document.getElementById('link2').style.display='none'; } else { console.log("None of the questions is 1"); document.getElementById('link1').style.display='none'; document.getElementById('link2').style.display='block'; } return; }

//How to structure your HTML to code. Onlick assigns value to x,y,z variables

<input type="radio" onclick="a1(1)" name="q1">Yes
<input type="radio" onclick="a1(0)" name="q1">No

//execute code
<button onclick="showdiv()">What Form Do I Need?</button>

//hide show divs using IDs
<div id="link1">
Link 1
<div id="link2">
Link 2

Force Update of PDFs

When replacing an existing PDF, browsers don’t serve the latest version. They usually serve the cached version. To change that, we use Apache directives as below:

# Instruct browsers to always check for the latest version of your files using Apache directives
<IfModule mod_headers.c>
<FilesMatch "(?i)^.*\.(css|htm|html|gif|jpg|jpeg|js|png|pdf)$">
Header set Cache-Control "max-age=0,must-revalidate"

The instruction above includes more than just PDF.

Another solution is using ?ver=x.x in the URL. For example:

x.x could be any number.

Source: “How to force an update of cached files, images, favicon

PHP Script Swapping out GA codes

This script was used to delineate Google Analytic Tracking codes between four different sites sharing the same wordpress theme files. Originally placed in footer.php above the GA tracking code provided by Google.

$host = 'https://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
if (strpos($host,'sls') !== false)
$gacode ="UA-792782-19";

elseif (strpos($host,'gai') !== false)
$gacode ="UA-792782-21";

elseif (strpos($host,'pep') !== false)
$gacode ="UA-792782-22";

elseif (strpos($host,'mvets') !== false)
$gacode ="UA-792782-23";

$gacode ="UA-792782-XX";

The script checks the URL and replaces the $gacode variable with the correct analytics code inside the provided GA script.

(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),

ga('create', '<?phpecho $gacode; ?>', 'auto');
ga('send', 'pageview');


Homepage Featured Events Display Using DOM

The featured events on the Mason Law homepage is pulled from the master calendar’s RSS. To get the dates and times separated from the titles, accessing the DOM is needed. The following codes, which requires jQuery, make the magic happened:

$this = $(this);
html('<em>' +

Sticky Nav on Scroll

Here’s a little JavaScript function to make your site’s header or navigation stick to the top of the window when users scroll the page:


<div id="navigation">
  <!-- your navigation code -->




// Handles the page being scrolled by ensuring the navigation is always in view.
function handleScroll(){
  // check that this is a relatively modern browser
  if (window.XMLHttpRequest){
    // determine the distance scrolled down the page
    var offset = window.pageYOffset
               ? window.pageYOffset
               : document.documentElement.scrollTop;
    // set the appropriate class on the navigation
    document.getElementById('navigation').className =
        (offset > 104 ? 'fixed' : '');
// add the scroll event listener
if (window.addEventListener){
  window.addEventListener('scroll', handleScroll, false);
  window.attachEvent('onscroll', handleScroll);

Source: “Detachable navigation using JavaScript

EMS Master Calendar Modification

  1. Connect to the server via Microsoft Remote Desktop
  2. Locate: C:\inetpub\wwwroot\MasterCalendar (under My Computer, C drive)

In order to add the Mason Law logo in the master calendar of events, I had to modify the master template file (Calendar.master). Scroll down to line 105, you’ll see this:

<div id="HeaderContainer" runat="server" class="HeaderContainer show-large" >
<div style="background-color:#063; width:100%;"><a href=""><img src="" alt="Antonin Scalia Law School, George Mason University" ></a><a href=""><img src="" alt="Calendar of Events" ></a></div>

<%--<div style="margin-bottom:20px;background-image:url(Images/ems-banner-bg.png)"><div class="centered" style="width:1423px;height:205px;"><img class="centered" src="Images/ems-banner.png"/></div>
<header:Header ID="Header" runat="server" />

This template needs to be update every time the EMS calendar is upgraded.