• twitter image
  • facebook image
  • youtube image
  • linkedin image
Language: CMS Made Simple Czech CMS Made Simple France CMS Made Simple Spain CMS Made Simple Hungary CMS Made Simple Russia CMS Made Simple Netherlands

All times are UTC




Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 10 posts ] 
Author Message
 Post subject: A Redirect UDT
PostPosted: Thu Aug 23, 2007 2:05 am 
Offline
Dev Team Member
Dev Team Member
User avatar

Joined: Tue Oct 19, 2004 6:44 pm
Posts: 8158
Location: Fernie British Columbia, Canada
Below you will find the code for a UDT to do redirecting.  I had to ask bbonora for this tag as I hadn't kept it.

Anyways.  Create a new UDT under Extensions >> Tags, and call it 'redirect'.  Then paste this code in there.

How do I use it:    add {redirect to='page_alias'} into one of your pages, or somewhere intelligently placed in your template (you should have an if statement around this, or you'll get some nasty redirection loops).

Code:
if( isset( $params['to'] ) )
  {
    global $gCms;
    $manager =& $gCms->GetHierarchyManager();
    $node =& $manager->sureGetNodeByAlias($params['to']);
    $content =& $node->GetContent();
    if (isset($content))
       {
         if ($content->GetURL() != '')
         {
            redirect($content->GetURL());
         }
       }
  }

_________________
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: A Redirect UDT
PostPosted: Thu Aug 23, 2007 4:52 pm 
Offline
New Member
New Member

Joined: Mon Aug 13, 2007 11:01 pm
Posts: 5
yes, thanks!  it's going into my code library for sure now!


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: A Redirect UDT
PostPosted: Fri Dec 07, 2007 4:28 pm 
Offline
Dev Team Member
Dev Team Member
User avatar

Joined: Tue Oct 19, 2004 6:44 pm
Posts: 8158
Location: Fernie British Columbia, Canada
Here's a slightly modified version with a bit more error handling

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'].' -->';
  }

_________________
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: A Redirect UDT
PostPosted: Sat Dec 08, 2007 12:47 pm 
Offline
Support Guru
Support Guru

Joined: Mon Jul 24, 2006 3:27 pm
Posts: 3679
Location: Paris
just wikied it.

@all : feel free to improve the documentation, as you have write access to the wiki with your forum account.

Pierre M.

_________________
-- Pierre, former support team member.
Please read "how to submit installation/support requests" before posting. Don't send private messages to ask for support.


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: A Redirect UDT
PostPosted: Mon Dec 17, 2007 12:41 am 
Offline
Forum Members
Forum Members
User avatar

Joined: Tue Aug 15, 2006 5:34 pm
Posts: 95
Location: Minnesota, USA
Love this UDT!!  Thanks much  ;D


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: A Redirect UDT
PostPosted: Tue Nov 16, 2010 2:57 am 
Offline
Forum Members
Forum Members

Joined: Tue Feb 02, 2010 5:02 am
Posts: 21
Is there a way to modify this for use with the FEU module, so the user can be redirected back to the original page they wanted once they login?  The "redirect after login" setting isn't useful for us, at least with a static page alias, but can the page alias be saved somehow at the original point of redirection, and used again with the redirect after login setting, maybe?

Any help greatly appreciated.

Erik


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: A Redirect UDT
PostPosted: Wed Aug 31, 2011 3:02 pm 
Offline
New Member
New Member

Joined: Wed Aug 31, 2011 2:36 pm
Posts: 2
How can I redirect on site with URL containing GET params?

For example if I want to redirect on this site:

path:
Code:
index.php?mact=Gallery,m721d7,default,1&m721d7dir=SamplePictures&m721d7returnid=56&page=56


When I use {redirect to='path'} it of course is not working, but when I use {redirect_url to='path'} on every place between params which are joined with & this character is replaced with &amp; and then is redirecting not working.

Has somebody any reason how to redirect on the page where I could use URL with params ? Because I spent so much time for rearching any solution.


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: A Redirect UDT
PostPosted: Wed Aug 31, 2011 5:27 pm 
Offline
Forum Members
Forum Members

Joined: Tue Feb 02, 2010 5:02 am
Posts: 21
My original request was resolved - details here:

viewtopic.php?t=49065

Hope it helps!

Erik


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: A Redirect UDT
PostPosted: Fri Sep 02, 2011 1:23 pm 
Offline
New Member
New Member

Joined: Wed Aug 31, 2011 2:36 pm
Posts: 2
Thanks for really fast answer.

I tried more ways how to resolve this problem and finally I have choosed this solution. This comment could be also included in some topics about gallery. Maybe this will help to somebody:

I use the same example as in my last comment:
path:
Code:
index.php?mact=Gallery,m721d7,default,1&m721d7dir=SamplePictures&m721d7returnid=56&page=56


The basic problem was that when somebody click on one of items from menu it was necessary to show specific gallery (default gallery) in content (page nr:65). But when I used tag
Code:
{Gallery dir='SamplePictures'}
it wasn't working. The gallery was showed, but it was really a mess on this side (styles, template). When I added more params to the tag gallery, the gallery-items in page-content are shown allright.
Code:
{Gallery dir='SamplePictures' returnid='56' page='56'}
I hope it's not necessary to use the param mact.

This script can help you redirect on page with specific gallery in content (m721d7 is probably ID of gallery).

Code:
{if $smarty.get.m721d7dir}
    {Gallery dir=$smarty.get.m721d7dir}
{else}
    {Gallery dir='SamplePicture' returnid='56' page='56'}
{/if}


So when is isset get param m721d7dir (in case if you redirect via anchor from another side and the link in anchor has param m721d7dir too) and when doesn't exist param m721d7dir then the default gallery shows.


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: A Redirect UDT
PostPosted: Sat Sep 03, 2011 11:46 am 
Offline
Forum Members
Forum Members

Joined: Tue Feb 02, 2010 5:02 am
Posts: 21
Excellent - thanks for sharing!

-Erik


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
Display posts from previous:  Sort by  
Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 10 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
A2 Hosting