Developer forum

Forum » CMS - Standard features » Link control adding http prefix

Link control adding http prefix

Scott Forsyth Dynamicweb Employee
Scott Forsyth
Reply

When using a paragraph of type item type, the field of  type "Link" adds a http:// prefix when I try to use a relative path. 

For example, I'll set the value of the field to "/test", save, and view the field again and it will become "http:///test". How can I avoid that? I want to use a relative path in some situations, but not always, so the Link control is the preferred control.

However, as a different example that works correctly, if going to Management Center and Direct Paths, the link picker there doesn't do it, even though it looks like the identical control.

Thanks,

Scott


Replies

 
Nicolai Pedersen
Reply

Hi Scott

You cannot avoid that. You would never have a link like that in Dynamicweb - because you do it 'wrong'

You would have either one of these

  1. Internal link, using the page selector, giving you "Default.aspx?ID=123" - Dynamicweb re-writes this to /test or whatever url the page has
  2. File link, starting with /Files/*
  3. External link - basically anything else. www.google.dk will be rewritten to http://www.google.dk
  4. Mail links some@somewhere.com gets the mailto protocol

The direct paths module has exceptions because its job is to handle urls that are not handled - i.e. by the above rules...

 
Scott Forsyth Dynamicweb Employee
Scott Forsyth
Reply

Hi Nicolai,

I should explain the situation better so that you can maybe guide me to a different alternative.

The issue is that occasionally we want to have something on the same site that isn't a page or paragraph. For example: /search?q=doorfastioners. An image carousel may link to a search results page. And we don't want to have the domain name in the URL since it could change. So we would like to have a site-relative URL. However, sometimes the image carousel will points to actual pages or paragraphs, so we want to use the link control and let the content editor choose which type of link they will use.

I see three possible solutions for this:

  1. Have the Link control support site relative URLs
  2. Add a free-text querystring part to the link control so that we can point to a page and still add a querystring addition
  3. Add a 2nd textbox, just for the querystring. If it's added, then it will get appended to the link

I bet you're going to tell me to go with #3. smiley If needed, that sounds like the best fallback options. But supporting relative URLs would seem cleaner. They are supported in some of the link controls throughout the backend.

Scott

 

 

 
Nicolai Pedersen
Reply
This post has been marked as an answer

Hi Scott

You can write Default.aspx?ID=123q=doorfastioners in the control for now or use your approach 3.

I've added a request to support /search?q=doorfastioners, TFS#29063

BR Nicolai

Votes for this answer: 1
 
Nuno Aguiar
Reply

Hi,

 

To help out with this, we add a "hidden" feature on all master templates on all projects. Go to the page you want to link to (no matter what querystring you end up on), view source and scroll all the way to the end. You will find both the RAW absolute and relative paths

http://www.screencast.com/t/7oRYWALZ

 

In Rowlf we took it a bit further exposing the relative path in the frontend when the user is logged in the backend (per customer's request)

http://www.screencast.com/t/eAhVd8DHPlO

 

Best Regards,

Nuno Aguiar

 
Scott Forsyth Dynamicweb Employee
Scott Forsyth
Reply

Thanks Nicolai, for creating a request for that, and also for the workaround. The Default.aspx? solution seems to work well.

And thanks Nuno, that confirms the URL pattern. That will work well now.

Scott

 

 

You must be logged in to post in the forum