George Mason University Antonin Scalia Law School

Main Site Top Navigation Bar

Assigning new pages to different sections of the site are done within the resource itself under Template Variables.

However, adding sections to the Top Navigation Bar requires manually editing a Chunks within MODX.

To add a new Admissions Program to the Admissions section, for example, Navigate to Elements, select Chunks, then Navigation, and select the nav_admissions chunk to manually add the page. Be sure to use Resource IDs in place of the URL.

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.

 

 

Upgrading to PHP 7

This guide is for CentOS Linux systems running PHP 5.3 and up.

Start by logging into WHM and making sure the server is on Apache 4. Use EasyApache 4 to upgrade if necessary.

To upgrade PHP 7, SSH into the server and download Remi and EPEL Repository:

$ wget -q http://rpms.remirepo.net/enterprise/remi-release-7.rpm
$ wget -q https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

Enable the respositories:

# rpm -Uvh remi-release-7.rpm epel-release-latest-7.noarch.rpm
FOR PHP 7.0 EXECUTE:
# yum-config-manager --enable remi-php70
FOR PHP 7.1 EXECUTE:
# yum-config-manager --enable remi-php71

Then upgrade to PHP 7:
# yum update

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>
<div id="link2">
Link 2
</div>

List All Sites Using Custom Shortcode

Shortcodes make it easier to customize wordpress pages quickly. WordPress comes with pre-built shortcodes but we’re going to build one from scratch. You will need to add a function to your child theme’s functions.php file. This particular code builds an ordered list of all our wordpress sites under our sls.gmu.edu domain using the get_sites() function. This function will work on all WP platforms 4.3 and above.


/*
* Author: Matthew
* This function creates a shortcode usable in all sites using the scalia law theme to create an ordered list of
all multisites
*/
function scalia_list_sites() {

$subsites = get_sites(); //creates variable using get_sites

if ( ! empty ( $subsites ) ) {

$html = '

    '; //sets up class

    foreach( $subsites as $subsite ) {

    $subsite_id = $subsite->blog_id; //finds sites by id
    $subsite_name = get_blog_details( $subsite_id )->blogname; //creates variable for site name
    $subsite_link = get_blog_details( $subsite_id )->siteurl; //creates variable for site url
    $html .= '< li class="site-' . $subsite_id . '">< a href="' . $subsite_link . '">' . $subsite_name . '< /a >< /li >'; //builds individual list items
    sort($html);
    }

    $html .= '< /ol >';

    return $html; //returns the list

    }

    }
    add_shortcode('scalia_list', 'scalia_list_sites'); //calls function and sets up [ scalia_list ] custom short code

    This goes in your child-theme’s functions.php file.

How to Renew SSL Certificate for law.gmu.edu

  1. Log into cPanel (GoDaddy) and go to SSL/TLS
  2. SSL screenshot

  3. Generate CSR and fill out all the information.
  4. Request SSL certificate from ITS. Submit a request to get a certificate.
  5. Once you get it from ITS, go back to cPanel – SSL and then go to certificates
  6. Then upload the .crt file that ITS gave you
  7. Go to Manage SSL Sites. Scroll down to the Install an SSL Website and click Browse Certificates. Select the certificate that you want to activate and click Use Certificate. Click Install Certificate.

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"
</FilesMatch>
</IfModule>

The instruction above includes more than just PDF.

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

https://www.law.gmu.edu/assets/css/2015/style.css?ver=2.0

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.

<?php
$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";
}

else
{
$gacode ="UA-792782-XX";
}
?>

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


<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

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

</script>

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:

$('.rssItemLink').each(
function(){
$this = $(this);
$this.
html('<em>' +
$this.
html().
replace(/((\d{1,2}\/){2}\d{2,4}\s*[0-9]{1,2}:[0-9]{1,2}\s*[apAP][mM]\s*to\s*[0-9]{1,2}:[0-9]{1,2}\s*[apAP][mM])/,
'</em><b>$1</b>'
)
);
}
);