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

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…

Caller – "Hi I'd like to help you update your Google listing"

Heard this before? Yeah me too. at least once a month a nice friendly voice claiming to be from Google calls me wanting help me update my Google listing.