If you’re scratching your head on how to get an HTTP redirect with CMS Made Simple, then save your scalp and scratch no longer!
All you need to do is create a User Defined Tag (UDT) within your CMS MS admin (Extensions > User Defined Tags), call the tag “redirect” and paste the following code:
if( isset( $params['to'] ) )
{
global $gCms;
$manager =& $gCms->GetHierarchyManager();
$node =& $manager->sureGetNodeByAlias($params['to']);
$content =& $node->GetContent();
if (isset($content) && is_object($content))
{
if ($content->GetURL() != '')
{
redirect($content->GetURL());
}
}
else return '<!-- redirect udt - page not found: '.$params['to'].' -->';
}
To use, add {redirect to=”page_alias”} into one of your pages, or somewhere intelligently placed in your template. If it’s going into a template then you should have an if statement around this, or you’ll get some nasty redirection loops!
Credit to calguy1000 for writing the function.
Further reading:
- http://wiki.cmsmadesimple.org/index.php/Share_your_tags_here#A_Redirect_UDT
- http://forum.cmsmadesimple.org/index.php/topic,14440.0.html
Update
I don’t know if they have always been there but I’ve since noticed the CMS Made Simple tags redirect_url and redirect_page
To use, insert into your page or template:
{redirect_page page="some-page-alias"}
or
{redirect_url to="www.cmsmadesimple.org"}
6 Responses to Page redirect with CMS Made Simple
Eoin November 7, 2008
Actually, I had to use double quotes to get the tag to work:
{redirect to=”page_alias”}
Joff November 7, 2008
Thanks for confirming that Eoin
leo rapirap August 10, 2010
hi i tried creating a page and put this is a content
{redirect_url urle=”http://www.google.com”}
but it didn’t work.
can you please shed a light on this one.
leo rapirap August 10, 2010
after investigating for another couple of hours, i finally made it work.
{redirect_url to=”http://www.google.com”}
Joff August 10, 2010
Thanks Leo, I’ve now updated the post with your syntax!
Erik November 16, 2010
Anyone know of a way to use this to save the page from which you’re redirecting, so you can go back to it after FEU login? I know this is posted without FEU in mind, but since FEU does not appear to have a way to bring the user to the page they originally wanted once they’ve logged in, I need to add that in. Any help appreciated! erik -at- bertpc dot com