Using page selector in widget designer to set external URL

Posted by Community Admin on 04-Aug-2018 15:00

Using page selector in widget designer to set external URL

All Replies

Posted by Community Admin on 03-Apr-2013 00:00

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.

Posted by Community Admin on 08-Apr-2013 00:00

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

Posted by Community Admin on 11-Apr-2013 00:00

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)?

Posted by Community Admin on 19-Apr-2013 00:00

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

Posted by Community Admin on 19-Apr-2013 00:00

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.

Posted by Community Admin on 24-Apr-2013 00:00

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

Posted by Community Admin on 25-Apr-2013 00:00

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 "yoursiteurl.com/.../LinkManagerDialog" you will see the dialog. There should be a way to reference that as a dialog in your own widget.

Thanks,

Chris

Posted by Community Admin on 30-Apr-2013 00:00

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

Posted by Community Admin on 13-Feb-2014 00:00

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.

Posted by Community Admin on 17-Feb-2014 00:00

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

This thread is closed