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

Forums / Developing with Sitefinity / Using page selector in widget designer to set external URL

Using page selector in widget designer to set external URL

10 posts, 0 answered
  1. Marko
    Marko avatar
    148 posts
    Registered:
    30 Jul 2008
    03 Apr 2013
    Link to this post
    Objective:
    I want to allow users to select a page from sitemap.  When the widget renders on public side, the selected page's URL is used to provide a hyperlink to that page.  In addition, I would like to allow users to provide an external link, if they so wish.

    What I have done so far:
    In my widget, I have a guid field for selected page.
    public Guid PageID { get; set; }

    Thunder created this in the designer ascx:
    <sf:PagesSelector runat="server" ID="pageSelectorPageID" AllowExternalPagesSelection="false" AllowMultipleSelection="false" />

    This works great and I'm able to select the page and save it.  In my widget logic, I use the supplied page guid to look it up using API and retrieve Full URL.  Great.

    Now, the second part.  How do I allow the external URL?

    I do see that if I set AllowExternalPagesSelection="true" I get two tabs at the top of page selector: From this site and From other sites.  How do I reference/store the "external" values?  Do i have to change my field from Guid type to some other type?  Do I create additional fields to store the supplied URL?

    An alternative would be to leave AllowExternalPagesSelection="false" and have a separate field for external URL.  But I thought this might be a good way to let the user do EITHER internal page OR external URL with built-in functionality.
  2. Stefani Tacheva
    Stefani Tacheva avatar
    718 posts
    Registered:
    21 Nov 2016
    08 Apr 2013
    Link to this post
    Hi Marko,


    I have decoupled the page selector field into a sample control that you can use instead of the built in field.
    Add the attached PageSelectorSample project to the sitefinty project and visual studio and it have added references to Sitefinity 5.3 assemblies (change the PageSelectorProject Telerik references if you want to use the field in different sitefinity version (5.4.4020).

    To use the field build in visual studio and it will generate PageSelectorSample.dll, add reference to the project .dll in your sitefinity site and  build it. To use the control:
    1. Add Global.asax to the project and in it register the PageSelectorSample dialog that will open for selecting pages.

    protected void Application_Start(object sender, EventArgs e)
            {
                Bootstrapper.Initialized += new EventHandler<Telerik.Sitefinity.Data.ExecutedEventArgs>(Bootstrapper_Initialized);
            }
      
            public void Bootstrapper_Initialized(object sender, Telerik.Sitefinity.Data.ExecutedEventArgs e)
            {
                Telerik.Sitefinity.Web.UI.Dialogs.RegisterDialog<PageSelectorDialog>();
            }

    Go to Administration->Settings->Advanced->VirtualPathSettings->VirtualPaths on the right click create new and enter

    VirtualPath: ~/CtrlSel/*
    ResourceLocation: PageSelectorSample
    ResolverType: EmbeddedResourceResolver

    save changes and restart the application for the virtual path to be in use otherwise the same error will be thrown.

    Create a custom field of type : PageSelectorSample.PageSelector.

    You might find the sample useful in your case.

    Greetings,
    Stefani Tacheva
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Marko
    Marko avatar
    148 posts
    Registered:
    30 Jul 2008
    11 Apr 2013
    Link to this post
    Stefani, thanks for your help, but I'm afraid that I'm not able to follow this code.  Where does this demonstrate how to hook into the "external" page value?

    Furthermore, is this a "sample" widget (demonstrating how to interact with the page selector), or are you suggesting that I reference this my custom widget, rather than using regular PageSelector?  If latter, then why?  What's wrong with the built-in PageSelector?  There isn't an easy way to interact with the external page value (which is available in the UI)?
  4. Stefani Tacheva
    Stefani Tacheva avatar
    718 posts
    Registered:
    21 Nov 2016
    19 Apr 2013
    Link to this post
    Hi,

    If I understand correct you want to have external URL in a custom widget designer. One possible solution in your case is to use PageField in conjunction with a text box to separately get an external URL from user.

    Greetings,
    Stefani Tacheva
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Marko
    Marko avatar
    148 posts
    Registered:
    30 Jul 2008
    19 Apr 2013 in reply to Stefani Tacheva
    Link to this post
    That's the approach I'm exploring right now.  That was my original assumption, actually, until I discovered the "AllowExternalPagesSelection" property, which reveals a nice external URL property in the UI.

    It's a shame there isn't a way to grab that value as easily as grabbing the Page GUID that's been set through the designer UI.
  6. Stefani Tacheva
    Stefani Tacheva avatar
    718 posts
    Registered:
    21 Nov 2016
    24 Apr 2013
    Link to this post
    Hello Marko,

    I agree with you and I will forward this communication to our developers.

    All the best,
    Stefani Tacheva
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  7. Chris
    Chris avatar
    11 posts
    Registered:
    10 Mar 2011
    25 Apr 2013 in reply to Marko
    Link to this post
    Marko,

    I know you are probably looking for a simple approach, however, if you have some time on your hands do some digging into the LinkManagerDialog.

    This is the dialog that the HtmlEditor in Sitefinity uses for links. If you go to "http://yoursiteurl.com/Sitefinity/Dialog/LinkManagerDialog" you will see the dialog. There should be a way to reference that as a dialog in your own widget.

    Thanks,

    Chris
  8. Stefani Tacheva
    Stefani Tacheva avatar
    718 posts
    Registered:
    21 Nov 2016
    30 Apr 2013
    Link to this post
    Hello,

    Thank you Chris for your help and for sharing your suggestions.

    All the best,
    Stefani Tacheva
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  9. Abhinav
    Abhinav avatar
    7 posts
    Registered:
    05 Feb 2014
    13 Feb 2014
    Link to this post
    Hello,

              I'm also facing such kind of problem. I've to include a external page in my project of Sitefinity so, there is an option Create a page when we click that there came an option with check box i.e. This page redirects to another page inside that as Marko told that there are 2 options From this site or From other site .I've to include a page of ASP.NET (.aspx) to this site I've entered the URL of that page but it is throwing 404 error of can't find page and not redirecting to that page. Please provide me the proper solution for this with format of URL to pass.
  10. Vassil Vassilev
     Vassil Vassilev avatar
    308 posts
    Registered:
    21 Jan 2015
    17 Feb 2014
    Link to this post
    Hello,

    In order to redirect to a aspx page, you need to the the following:
    • create the aspx page (e.g. Test.aspx)
    • build your project, you can also test if your page is properly build by right-click > display in browser (under Visual Studio). 
    • go to Sitefinity backend, click Title&Properties > check "This page redirects to another page" and browse web address
    • enter ~/Test.aspx

    If you do this, the page will redirect to {yourdomain}/Test.aspx

    I hope this helps.

    Regards,
    Vassil Vassilev
    Telerik
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
10 posts, 0 answered