It links to a page that does not exist? Not sure I get that...if it returns an id...then there must be a page? But is it because it's not a page but a content element? Sorry if I'm being slow here but just trying to understand the issue fully :)
Not sure if I understand the issue either but I experienced a similar situation some time ago. It may be a long-shot, but my problem was that I forgot to published the page.
Ok, still not sure that your explanation makes sense - You will want the urlName and not the page name in the href, right? :) Huge difference. But think I get it now...
Could you use the @Umbraco.Content() helper to feed the id into so you can get the url like...
@Umbraco.Content(item.showcaseLink).Url - Does this make sense? And does it work?
The call is ambiguous between the following methods or properties: 'Umbraco.Web.UmbracoHelper.Content(params int[])' and 'Umbraco.Web.UmbracoHelper.Content(params string[])'
Output NiceUrl instead of page ID
Hi
I have this code which outputs the page ID instead of the page name. I use the content picker to choose which page to link to.
I found this post:
https://our.umbraco.org/forum/developers/razor/45195-Attempting-to-get-nice-url-from-Ultimate-Picker
But I can't get it to work.
// René
Hi René
So @item.Url does not work? What happens if you try using it? Nothing gets rendered or you get an error?
Have you ensured that the link is never empty? I'm thinking that perhaps some entries have a link and others don't?
/Jan
Hi Jan
If I just use @item.Url does not work because it links to a page that does not exist.
I need to show the link that I have choosen with the content picker:
@item.showcaseLink
It works but the link is an ID like this - localhost:37598/1058/
I want it to be localhost:37598/profilbeklaedning/
I thought that I could use NiceUrl but as far as i know then it does not work with Umbraco 7.
// René
Hi René
It links to a page that does not exist? Not sure I get that...if it returns an id...then there must be a page? But is it because it's not a page but a content element? Sorry if I'm being slow here but just trying to understand the issue fully :)
/Jan
Hi,
Not sure if I understand the issue either but I experienced a similar situation some time ago. It may be a long-shot, but my problem was that I forgot to published the page.
Hi Jan
That's okay I also find it difficult to explain correctly. :-)
What I need is a internal link to a subpage. The internal link is choosen with the content picker.
At the moment it works, but the link to the subpage is outputted with the page ID and I would like it to output the page name instead.
Is that possible when using the content picker?
// René
Hi René
Ok, still not sure that your explanation makes sense - You will want the urlName and not the page name in the href, right? :) Huge difference. But think I get it now...
Could you use the @Umbraco.Content() helper to feed the id into so you can get the url like...
@Umbraco.Content(item.showcaseLink).Url
- Does this make sense? And does it work?/Jan
Hi Jan
Sorry....Yes it is the urlName I need.
Your code works perfect.
// René
Hi René
No need to be sorry - I just get a bit confused :D
Happy to be able to help and getting better at reading between the lines ;-)
/Jan
Hi
I am using Jan Skovgaard's code in new project and now it is not working. My code looks like this:
}
Now I get this error message:
The call is ambiguous between the following methods or properties: 'Umbraco.Web.UmbracoHelper.Content(params int[])' and 'Umbraco.Web.UmbracoHelper.Content(params string[])'
What am I doing wrong?
//René
Hi René
Have you considering use the helper method called NiceUrl, with this you should get what you are after.
If you have a case where you the full domain, there is a helper method for that as well. NiceUrlWithDomain.
The documentation can be found here just search for NiceUrl. https://our.umbraco.org/documentation/Reference/Querying/UmbracoHelper/
Hope this helps,
/Dennis
Hi Dennis
I have followed your advice and that solved my problem. My code now looks like this:
Thank you!
// René
is working on a reply...