A few of the thoughts from my head in no particular order

Page redirect with CMS Made Simple

September 12th, 2008 Posted in web, work

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:

  1. 2 Responses to “Page redirect with CMS Made Simple”

  2. By Eoin on Nov 7, 2008

    Actually, I had to use double quotes to get the tag to work:
    {redirect to=”page_alias”}

  3. By Joff on Nov 7, 2008

    Thanks for confirming that Eoin

Post a Comment