I'm attempting to direct a child Resource to it's parent. Using MODx Revo 2.1.3-pl.
I initially tried making the child Resource a modsymlink and then a modweblink and put
in the weblink input field in order to redirect to the direct parent. But the link in Wayfinder was directing to the ultimate parent (which was a few levels up) and not the direct parent. I've just stuck some redirect JS in the head for now, but was wondering if there was a cleaner way to do this in MODx?
Precision Web Development ... SmashStack.com
-
- 24,544 Posts
A snippet with this should do it (if I'm understanding what you want).
$modx->sendRedirect($modx->makeUrl($modx->resource->get('parent')));
Hey Bob,
That did the trick...thanks so much!
By the way, can't wait to get your book in the mail...checking the mail box everyday!
Precision Web Development ... SmashStack.com
-
- 24,544 Posts
Quote from: flinx777 at Sep 07, 2011, 05:01 AM
By the way, can't wait to get your book in the mail...
Me too.
-
- 1 Posts
Would this be considered a 301 redirect? If not, how would you add that?
-
- 24,544 Posts
It defaults to a 302. You can send a 301 like this:
$modx->sendRedirect('http://modx.com',array('responseCode' => 'HTTP/1.1 301 Moved Permanently'));
If it's really a permanent redirect, though, you might consider using a rewrite rule in .htaccess.