Knowledge Base/Official Insight Help/Site Structure (groups)

How can I redirect a menu option/group to another location?

Justin Ruffell-Ward - Insight Support
posted this on December 10, 2010 17:02

You can forward a group (option on the menu) to a different area of the site by adding a simple script to an article.

For example you may want to have an area e.g.Students located in 2 different areas of your site structure but wish to direct them to one area for information about that topic so you don't have to duplicate the material. Another example where this might be used is when you which to move the location of one of the system pages, e.g.if you wish to move the monthly calendar from below the 'Home' menu to a more prominent place within your site's navigation structure.

Both these examples would be achieved in the following way:

  • Copy the url location of the page you wish to direct the user to e.g.if you were wishing to add an option for the monthly calendar you would go to the monthly calendar and copy the url from the address bar of your browser i.e./Calendar/Month.aspx .
    Note: if you are forwarding to a page on your web site you don't need to include your domain name, you only need the part of the address after your domain name. This is called a relative link and means if would work even if you changed your site domain name.
  • Create a group that you want to setup the forward within. e.g.if wishing to move the location of the monthly calendar you would create a new group for the monthly calendar in the position you require within your site structure.
  • Create an article within the newly created group and add the script to an article. First create a new article within your newly created group. When the document editor loads select the 'Source' option from the editor's toolbar (it's the last option on the far-right of the toolbar options). Replace the text that appears in the 'source' with the following code:

    Forward Scripts
    There are two options for linking to a web page from your menu bar.
    1. You can make the user go straight to the link from your site in the same window.
    2. You can choose to open the link in a new window so a user remains on your site in the original browser window.

    Replacing your page with the page you are linking to
    Paste in the script below replacing the URL (in red) with the URL you wish to forward to.

    <script type="text/javascript">
    if (window.location.href.indexOf('/aspnet_client/') < 0){
    window.location = "/Group/Group.aspx?ID=18617"; }
    </script>

    Opening the link in a new window
    To add a script that will open the link in a new window please use the code below replacing the URL in red with the address you wish to forward your user to.

    <script type="text/javascript">
    if (window.location.href.indexOf('/aspnet_client/') < 0){
    window.open("Group/Group.aspx?ID=18617");
    history.go(-1);
    }</script>

    Note: A user's browser settings may block a link opened in a new window if they have pop-up blocker enabled in their browser.
  • Publish your article, giving it a name.
  • Make your article a group homepage article by clicking on the house icon in the documents tab to the right of the document title. Your newly created group should now forward you to your new location.
    Note:The forward will only work if you have a layout with an Article component set to display the group homepage
  • Your forward should now be complete - test it and see.

 

 

Comments

User photo
Chris Meersman

I followed these easy to follow instructions - but the redirect did not work.  Please check the script I used and tell me what I dod wrong.

<script type="text/javascript">
if (window.location.href.indexOf('/aspnet_client/') < 0){window.location = "/Contact_Us/Contact_Us.aspx"; }
</script>

February 13, 2011 01:34
User photo
Kevin King

Try checking the source code to see if it contains a line break between /Contact_Us/ and //Contact_Us.aspx'. The document editor doesn't understand source code and occasionally inserts breaks in inappropriate places.

May 14, 2011 17:30
User photo
Justin Ruffell-Ward - Insight Support
Endis

Chris, is the article containing the script definitely being called? Perhaps it's in layout that loads the group homepage article but it has not been set to be the group homepage.

If this isn't the reason let us know your website url and I'll take a look.

May 16, 2011 10:07
User photo
Chris Meersman

I got this working now.  I had an error in the syntax.  Thank you!

May 23, 2011 00:09
User photo
Chris Meersman

This feature works pretty well and it's easy to set up but when you click on the menu option/group that is getting redirected to another page on the site, the whole screen jerks to the right and left as the new page is loading.  Is there a way to make the transition seamless?

June 05, 2011 04:52
User photo
Kevin King

The way I got over this was to place the redirection article in a sub-group and give that subgroup its own stylesheet and layout, based on the blank layout from the theme park. The layout I used contained nothing except the redirection article, which I placed in the header bar, and the footer bar. No graphics, etc., just a simple, centered, redirection message in a 100% width div. That fixed it for me.

June 05, 2011 12:50
User photo
Kevin King

You may also be interested to know that it is possible to go a step further with this trick, by creating two redirection articles, diverting the user to different parts of the site depending on their access permissions. You then embed these articles within a third article, and make that article the target of the initial link.

June 05, 2011 12:55
User photo
Chris Meersman

I'm not following you; please explain further.  I have 15 groups that are my primary groups and each has an Article.  I also have 30 phantom groups (2x15) that are nothing more than pages that should redirect to to the 15 primary group articles.  When someone clicks on the phantom group, there will be a redirect to the primary.  During this redirect, the whole website momentarily shifts to the far right of the screen and then back again before painting the redirected page.  I am trying to find a way to eliminate the visible redirect jerky page action.

June 06, 2011 04:53
User photo
Kevin King

From my experience, the judder you are describing seems to occur because the system begins to render the page containing the redirect, then encounters the redirect instruction and begins to execute that, leaving the partially-rendered (and often incorrectly aligned) image on the screen while it does so. By setting the theme (aka style sheet) and layout of the group containing the redirect (your phantom groups) to a simple 'vanilla' colour scheme and minimalist layout, as described in my first response, the browser has nothing much to display whilst the redirect is executing; so the effect is generally that of a slightly extended pause before the new screen is rendered. If you still get a sideways judder, try tweaking the 'Page Layout'/'Alignment'/'Left Padding' and 'Right Padding' settings in the theme of the group containing the redirection: but be careful not to accidentally change your main theme and layouts.

The more complex arrangement I described in my second response is one I am using for situations where a single link from an article has to be redirected, depending on the user's access rights, to locations that utilise completely different themes and layouts. In that situation, the last thing I want is for the user to get a momentary glimpse of the alternate colour scheme and layout before the redirected page appears.

June 06, 2011 22:25
User photo
Neal Thorne

In my attempt to limit access to the address book to only certain people, I created a seperate Address book group, and then added the above mentioned redirect script within the article of  that page, allowing people who are a part of that group access to the address book.  Sounds great, however when I went to disable the address book so that it would not show up under the HOME menu, it then disabled the redirect page I had created.  Is there a way to have a redirect as I have created, but also remove the Address book from the home dropdown menu without completely disabling it...

November 24, 2011 17:52
User photo
Kevin King

Hi, Neal!

The problem here is that the address book really needs a mechanism for disabling it in certain groups or layouts, instead of being a default on or off. Otherwise, even if you used clever programming to hide it, a clever hacker could probably get at it. But have you considered the alternative strategy of creating members-only areas as independent groups and leaving the rest of the site open to any visitor?

December 08, 2011 11:24
User photo
Kevin King

Note also that you can prevent people from accessing the address book by setting your Address Book policy to exclude non-members. However, if you want to discuss this further, I think you'd better start another topic.

December 08, 2011 11:40