+1-888-365-2779
Try Now
More in this section

Forums / General Discussions / external pages on sitemap

external pages on sitemap

17 posts, 0 answered
  1. Vangelis
    Vangelis avatar
    153 posts
    Registered:
    07 Jan 2006
    24 Aug 2007
    Link to this post
    Hi,

    I have included an external page in the sitemap. Is there any option to setup it to open in a new window in case of an other site? It is very useful in some cases just to be able to return in the originated site.

    Best regards

    Vagelis
  2. Pepi
    Pepi avatar
    981 posts
    Registered:
    28 Oct 2016
    27 Aug 2007
    Link to this post
    Hello Vagelis,

    Unfortunately, there is no option that you could set to open the external pages in a new window. But you could provide your own implementation of the required functionality. For example, you could write a method handling OnItemDataBound event of the navigation control and add the necessary code in it:

    public void RadMenu1_ItemDataBound(object sender, RadMenuEventArgs e) 
            CmsSiteMapNode node = e.Item.DataItem as CmsSiteMapNode; 
             
            if (node != null && node.CmsPage.PageType == CmsPageType.External) 
            { 
                e.Item.Attributes.Add("onclick", "window.open('" + node.CmsPage.ExternalUrl + "')"); 
                e.Item.NavigateUrl = ""
            } 
     

    Another solution is to set "_blank" for the Target property of the navigation control item:

    e.Item.Target = "_blank";


    The example is for the RadMenu but the implementation is analogical for all navigation controls.

    Hope this helps.

    Kind regards,
    Pepi
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. Meister
    Meister avatar
    262 posts
    Registered:
    09 Nov 2007
    12 Nov 2007
    Link to this post
    hi

    which files would i need to edit to implement the RadMenu1_ItemDataBound solution?

    thanks
  4. Gabe Sumner
    Gabe Sumner avatar
    440 posts
    Registered:
    09 Sep 2007
    13 Nov 2007
    Link to this post
    Hi Quade,

    Regarding the file you would have to alter; it will probably depend on what control you are using to render the links in the first place. 

    For example, let's say you're using "Sitemap Tree View" to render your links.  Then you will probably need to alter:

    ~/Sitefinity/UserControls/Navigation/SiteTreeview.ascx.cs

    If you are using the "Sitemap Tabstrip" control, then you will need to alter:

    ~/Sitefinity/UserControls/Navigation/SiteTabstrip.ascx.cs

    I haven't personally done this, but I'm seeing a "NodeBound" method in these controls.  You might be able to tack on some code into this method to accomplish what you wish.

    Best of luck!

    Gabe
    ===============
  5. Meister
    Meister avatar
    262 posts
    Registered:
    09 Nov 2007
    13 Nov 2007
    Link to this post
    thanks gabe

    i'm using
    ~/Sitefinity/UserControls/Navigation/sitemenu.ascx.cs

    and i've located the current item databound

    public void RadMenu1_ItemDataBound(object sender, RadMenuEventArgs e)


    and i've put this bit of code near the bottom, however, its not working


    public void RadMenu1_ItemDataBound(object sender, RadMenuEventArgs e){

    if (this.hideUrlForGroupPages)

    {

    CmsSiteMapNode node = e.Item.DataItem as CmsSiteMapNode;

    if (node != null && node.CmsPage.PageType == CmsPageType.Group)

    {

    e.Item.NavigateUrl = "";

    }

    }

    CmsSiteMapNode node2 = SiteMap.CurrentNode as CmsSiteMapNode;

    if (node2 != null && node2.ParentNode != null)

    {

    while (node2.ParentNode != SiteMap.RootNode)

    {

    RadMenuItem item2 = this.RadMenu1.FindItemByUrl(this.ResolveUrl(node2.Url));

    if (item2 != null)

    item2.CssClass = this.selectedItemCssClass;

    node2 = node2.ParentNode as CmsSiteMapNode;

    }

    RadMenuItem item = this.RadMenu1.FindItemByUrl(this.ResolveUrl(node2.Url));

    if (item != null)

    {

    // here you can set the style for the top-level item

    item.CssClass = this.selectedItemCssClass;

    }

     

     

    }

    //this bit is the code i've inserted

    CmsSiteMapNode node = e.Item.DataItem as CmsSiteMapNode;

    if (node != null && node.CmsPage.PageType == CmsPageType.External){

    e.Item.Target = "_blank";

    }

    }




    however this doesn't work as it errors on the mode bit (see underlined)

    Error is
    A local variable named 'node' cannot be declared in this scope because it would give a different meaning to 'node', which is already used in a 'child' scope to denote something else

  6. Pepi
    Pepi avatar
    981 posts
    Registered:
    28 Oct 2016
    13 Nov 2007
    Link to this post
    Hi Quade,

    The error is caused by the fact that you are trying to declare a variable that already exists. A variable named node is declared at the beginning of RadMenu1_ItemDataBound method. For more information on this error please refer to the following articles.

    For example, you could modify
    RadMenu1_ItemDataBound as follows:

    public void RadMenu1_ItemDataBound(object sender, RadMenuEventArgs e) 
        { 
            CmsSiteMapNode node = e.Item.DataItem as CmsSiteMapNode; 
     
            if (this.hideUrlForGroupPages) 
            { 
                if (node != null && node.CmsPage.PageType == CmsPageType.Group) 
                { 
                    e.Item.NavigateUrl = ""
                } 
            } 
     
            if (node != null && node.CmsPage.PageType == CmsPageType.External) 
            { 
                e.Item.Target = "_blank"
            } 
            ... 
        } 

    Hope this helps.

    All the best,
    Pepi
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  7. Meister
    Meister avatar
    262 posts
    Registered:
    09 Nov 2007
    13 Nov 2007
    Link to this post
    thanks, i guessed that.

    based on the code i posted and the code posted at the top of the thread, what would be the correct code to get this solution working?

    thanks
  8. Pepi
    Pepi avatar
    981 posts
    Registered:
    28 Oct 2016
    13 Nov 2007
    Link to this post
    Hi Quade,

    As I have already mentioned in the post from 8/27, there are two alternative solutions for this issue:
    1. Associate an Attribute to the menu item.
    2. Set the Target property of the menu item to _blank.

    So you will achieve the required functionality with either of the two approaches. I recommend the second one as it is  clearer and simpler.

    Kind regards,
    Pepi
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  9. Meister
    Meister avatar
    262 posts
    Registered:
    09 Nov 2007
    13 Nov 2007
    Link to this post
    thanks for you help


    however, i dont know where to edit this setting. could you be more specific please.
  10. Pepi
    Pepi avatar
    981 posts
    Registered:
    28 Oct 2016
    14 Nov 2007
    Link to this post
    Hello Quade,

    We recommend you copy the SiteMenu User Control located in  /<your_project>/Sitefinity/UserControls/Navigation/ folder and then do the necessary implementation as described in the posts so that after upgrade, no changes will affect your settings (otherwise they  will be lost ).

    You could find more information how to use User Controls in Sitefinity environment in the User Manual, chapter Working with Controls -> Uploading Controls.

    Hope this helps.

    Regards,
    Pepi
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  11. Allen
    Allen avatar
    71 posts
    Registered:
    04 Aug 2007
    29 Feb 2008
    Link to this post
    I agree with Quade that adding the target attribute in the designer would be a really good idea.  While it is a great idea for external links it is also just a good idea for "regular" pages as you may not always want your user to navigate away from the page they are on (as in a "help" link).

    Anyway, following on to the external link issue, is there a way to edit the code for the admin site so that if a page is an external link that the designer does not attempt to draw the page?  Some sites really don't like being nested in a frame or iframe and it causes issues in the designer.

    Thanks
  12. Nikifor
    Nikifor avatar
    232 posts
    Registered:
    18 May 2013
    05 Mar 2008
    Link to this post
    Hello Allen,

    Thank you for your feedback.

    Maybe there is a possible workaround for the question you have, but the logic about it would be a bit complicated. You can check the PageViewer template stored in ~\YourProject\Sitefinity\Admin\ControlTemplates\Pages which is used for page preview. We are using iframe for visualizing it. If you can modify the code and set a verification for external pages (whether the page is external for your domain) maybe you will be able to prevent external pages from displaying so only such on localhost will be previewed.

    Of course, this is just an idea and the scenario is not tested on our side. If you have the needed resource you can try modifying the PageViewer.ascx so it could suit your requirements.

    Hope the provided information is helpful. Do not hesitate to contact us if you need any clarifying information.

    All the best,
    Nikifor Hristov
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  13. Jim Hudson
    Jim Hudson avatar
    1 posts
    Registered:
    26 Aug 2009
    08 Sep 2009
    Link to this post
    This thread seems very old.  Has Telerik provided a new sitemenu version with the support for _blank yet?

    Thanks,
    Jim
  14. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    08 Sep 2009
    Link to this post
    Hello Jim Hudson,

    There is no implementation for openning RadMenu items in new window. You can easily implement it.

    1. Create a property of boolean type

    [DefaultValue(false)] 
        public bool _Blank 
        { 
            get 
            { 
                return this.newWindow; 
            } 
            set 
            { 
                this.newWindow = value; 
            } 
        } 
        private bool newWindow; 

    2. Then change the logic under RadMenu_ItemDataBound event

    public void RadMenu1_ItemDataBound(object sender, RadMenuEventArgs e) 
        { 
            if (this.newWindow) 
            { 
                CmsSiteMapNode siteNode = e.Item.DataItem as CmsSiteMapNode; 
                if (siteNode != null
                { 
                    e.Item.Target = "_blank"
                } 
            } 
        .... 
          ..... 
      } 

    Note that this will open all items in new window. If you want to open only certain items you need to extend the logic above by getting the e.Item.Text  and setting the boolean property.

    All the best,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  15. Brimaka
    Brimaka avatar
    6 posts
    Registered:
    08 Nov 2009
    18 Dec 2009
    Link to this post
    If you wish to open an external page from a RadTabStrip, I have found a way of doing this.

    When loading the tabstrip control and iterating through nodes of the tabstrip, check to see if the node points to an external page.  If it is, set the node target.

    if (((CmsSiteMapNode)node1).CmsPage.PageType == CmsPageType.External)  
       tab.Target = "_blank";  
     

    The full Page_Load method ends up looking something like this:

        protected void Page_Load(object sender, EventArgs e)  
        {  
            if (this.ShowOnlyFirstLevel)  
            {  
                SiteMapNode rootNode = SiteMap.RootNode;  
                foreach (SiteMapNode node1 in rootNode.ChildNodes)  
                {  
                    RadTab tab = new RadTab();  
                    tab.Text = node1.Title;  
                    tab.NavigateUrl = node1.Url;  
     
                    if (((CmsSiteMapNode)node1).CmsPage.PageType == CmsPageType.External)  
                        tab.Target = "_blank";  
     
                    this.RadTabstrip1.Tabs.Add(tab);  
                }  
                .  
                .  
                .  
        } 

    Hope this helps.
  16. Bachar Zeidan
    Bachar Zeidan avatar
    67 posts
    Registered:
    01 Jul 2010
    27 Jan 2011
    Link to this post
    Hi Telerik,
    I need this feature in the PanelBar control. Can you give me the code to apply the solution posted above in my control?

    Thanks,
    Bachar
  17. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    27 Jan 2011
    Link to this post
    Hi,

    You can do this inside RadPanelbar1_ItemDataBound inside

    Sitefinity\UserControls\Navigation35\SitePanelbar.ascx.cs

    public void RadPanelbar1_ItemDataBound(object sender, RadPanelBarEventArgs e)
       {
           if (this.hideUrlForGroupPages)
           {
               CmsSiteMapNode node = e.Item.DataItem as CmsSiteMapNode;
               if (node != null && node.PageType == CmsPageType.External)
               {
                   e.Item.Target = "_blank";
                 
               }
           }
       }


    Greetings,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Register for webinar
17 posts, 0 answered