Having same issue, but have something that works, if it could be undertood why it works (it's not pretty), maybe we can head to a solution.
Using V6 in Mvc.
var pages = CurrentPage.AncestorOrSelf("topNode").Descendants().Where("DocumentTypeAlias == \"ChildNode\"");
@pages.Url() - should work, but does not: (object not set to a reference - null error)
However, @foreach (var item in pages){
<a href="@item.Url()">link</a>
}
does work. In effect it is looping on a single node, so I guess the question is what does the forech "use" to pull the property?
Have tried this in all combinations, but will only return the value if the loop is included.
Used Model.Content etc to get Intellisense, but it offers nothing useable after the Where statement, my belief is that there is something missing - but I have no idea what. Was running this in a partial, then direct into main page, just to check, it made no difference.
Apologies for not having an answer, but maybe together and with a bit of help we can find a solution.
Many thanks - yes that works, but only for one NodeId - I need to get to the documentType as this is for a button to a booking form, so for each of the "sections" the nodeId is different, there is nothing in the helper that I can see that will give me this.
Surely there must be a simple way to achieve this?
That doesn't really help, yes I can add multiple nodeIds, but, is it not much simpler to call the documentType instead of having to add the new node everytime a new "section" is added?
I think I have been through all the possiblities, but put very simply I want to go to the parent node, come back down, find the documentType (which is unique) and get the Url to add to a button to take user to that page. I have never had an issue doing this in previous versions, just can't find a way to achieve it in V6.
Or maybe I am missing something really obvious? It does happen.
The IContent object does not provide a Url. Are you trying to query Umbraco for IContent to use that on the frontend? IContent is NOT cached content and goes straight to the database it is not advisable to use it on the frontend. I don't know what exactly you're trying to do but something like this will work:
I'm actually running into this as well. I'm importing a bunch of content over from Sitecore & need the new url during import to set up the approriate redirects. I know that url generation is based on the xml cache structure, but it seems like there should be some way to get at it from deeper inside.
apologies for very late reply, am posting this from my phone a my computer is dead, and a new one may take.some time.to arrive.
this all happened in 6.0, think it was the RC, it was to do with dynamic content not returning as it should, or the content not saving correctly, or.maybe a combination of the two.
Should.be marked as solved, or gone.away, but will do it when i can find it via this device while i juggle with the magnifying glass to try to see anything.
Not the easiest ofthings to achieve, the forum on a mobile, but needs must and all that.
How to get NiceUrl from IContent object in Umbraco 6?
Hi
In Umbraco 6, using new APIs, How to get NiceUrl from IContent object for content node?
Thanks & Regards
Pinal Bhatt
Similar unanswered post http://our.umbraco.org/forum/developers/api-questions/38261-Umbraco-6-New-API-How-do-I-get-a-URL ;
Similar unanswered post http://our.umbraco.org/forum/developers/api-questions/38261-Umbraco-6-New-API-How-do-I-get-a-URL ;
I'll follow this too - this is a real blocker for me adopting the new API
Hi Pinal & Keith
Having same issue, but have something that works, if it could be undertood why it works (it's not pretty), maybe we can head to a solution.
Using V6 in Mvc.
var pages = CurrentPage.AncestorOrSelf("topNode").Descendants().Where("DocumentTypeAlias == \"ChildNode\"");
You could try to use the UmbracoHelper. If you have the helper availabile you could do this:
Jeroen
Hi Jeroen
Thanks for reply - have to admit this has confused me - something so simple
from above @pages.Umbraco.Url() gives the following error
Umbraco.Web.Models.DynamicPublishedContentList' does not contain a definition for 'Umbraco'
also intellisense saying NiceUrl is deprecated, use Url.
Unless I am not using the helper correctly, or not calling the correct using statements?
All seems to work up until the where statement, then without the loop there are no definitions as you would expect.
Any help would be much appreiated - ok it runs for now, but would prefer a solution to the workaround.
Regards
Gary
You can find more info about the Umbraco Helper here:
http://umbraco.com/follow-us/blog-archive/2012/10/30/getting-started-with-mvc-in-umbraco-410.aspx
Jeroen
Hi
Many thanks - yes that works, but only for one NodeId - I need to get to the documentType as this is for a button to a booking form, so for each of the "sections" the nodeId is different, there is nothing in the helper that I can see that will give me this.
Surely there must be a simple way to achieve this?
Regards
Gary
The helper has a TypedContent method in which you can pass multiple id's which will return the nodes which contain the url. More info here: http://our.umbraco.org/forum/developers/api-questions/37894-new-Dynamic(id)-and-new-Node(id)-equiv-in-v6
Jeroen
Hi Jeroen
That doesn't really help, yes I can add multiple nodeIds, but, is it not much simpler to call the documentType instead of having to add the new node everytime a new "section" is added?
I think I have been through all the possiblities, but put very simply I want to go to the parent node, come back down, find the documentType (which is unique) and get the Url to add to a button to take user to that page. I have never had an issue doing this in previous versions, just can't find a way to achieve it in V6.
Or maybe I am missing something really obvious? It does happen.
regards Gary
So many responses but still no satisfactory answer. How to get NiceUrl from IContent object for content node?
The IContent object does not provide a Url. Are you trying to query Umbraco for IContent to use that on the frontend? IContent is NOT cached content and goes straight to the database it is not advisable to use it on the frontend. I don't know what exactly you're trying to do but something like this will work:
See the documentation at: http://our.umbraco.org/documentation/Reference/Mvc/querying
I'm actually running into this as well. I'm importing a bunch of content over from Sitecore & need the new url during import to set up the approriate redirects. I know that url generation is based on the xml cache structure, but it seems like there should be some way to get at it from deeper inside.
Is IContent not an interface?
Gary i am confused as to what the problem is? :). Charlie.
hi Charlie
apologies for very late reply, am posting this from my phone a my computer is dead, and a new one may take.some time.to arrive.
this all happened in 6.0, think it was the RC, it was to do with dynamic content not returning as it should, or the content not saving correctly, or.maybe a combination of the two.
Should.be marked as solved, or gone.away, but will do it when i can find it via this device while i juggle with the magnifying glass to try to see anything.
Not the easiest ofthings to achieve, the forum on a mobile, but needs must and all that.
cheers for your input
regards
gary
is working on a reply...