MODx Plugin for Resource Redirecting

So Abraham got to work and adapated the example Page Not Found MODx Plugin to work as follows: forwards to (301) .

The Plugin Code

Create a new plugin, name it whatever you'd like resourceRedirect. Then on System Events check OnPageNotFound.

 <?php if ($modx->event->name == 'OnPageNotFound') { $output = ''; $param_alias = $modx->getOption('request_param_alias'); $get = $modx->getOption('GET', $modx->request->parameters, ''); $rId = $modx->getOption($param_alias, $get, ''); if(!is_numeric($rId)) { 41return $output; } $rId = intval($rId); $resource = $modx->getObject('modResource', array('id'=>$rId)); if($resource) { $url = $modx->makeUrl($resource->get('id')); $modx->sendRedirect($url); return $output; } } 

Recent Posts

The Status of Liquid Web Cloud Sites Formerly of Rackspace in 2018

We've been a cloudsites customer since our inception, it's had ups and downs, here is what we think about it now.

OG Image Branding with phpThumb and MODX

Some of our clients have wanted to make sure their logo and branding appear in facebook, twitter, or messaging apps when shared. We came up with a clever solution.

Photography for the web

Did someone send you this link? First: Know that it is meant only as a guide. It's not that you can't shoot great photos, this is just to help you capture the best photography possible to be used in marketing. Photos…