Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Pinal Bhatt 298 posts 389 karma points
    Feb 11, 2013 @ 17:53
    Pinal Bhatt
    0

    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

  • Pinal Bhatt 298 posts 389 karma points
    Feb 11, 2013 @ 18:02
  • Pinal Bhatt 298 posts 389 karma points
    Feb 11, 2013 @ 18:02
  • Keith Jackson 183 posts 552 karma points
    Feb 11, 2013 @ 18:04
    Keith Jackson
    0

    I'll follow this too - this is a real blocker for me adopting the new API

  • gary 385 posts 915 karma points
    Feb 20, 2013 @ 10:57
    gary
    0

    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\"");

    @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.
    Regards
    Gary
  • Jeroen Breuer 4860 posts 12127 karma points MVP 3x admin c-trib
    Feb 20, 2013 @ 12:22
    Jeroen Breuer
    0

    You could try to use the UmbracoHelper. If you have the helper availabile you could do this:

    Umbraco.NiceUrl(id)

    Jeroen

  • gary 385 posts 915 karma points
    Feb 20, 2013 @ 12:33
    gary
    0

    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

  • Jeroen Breuer 4860 posts 12127 karma points MVP 3x admin c-trib
    Feb 20, 2013 @ 12:40
    Jeroen Breuer
    0

    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

  • gary 385 posts 915 karma points
    Feb 20, 2013 @ 13:07
    gary
    0

    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

  • Jeroen Breuer 4860 posts 12127 karma points MVP 3x admin c-trib
    Feb 20, 2013 @ 13:10
    Jeroen Breuer
    0

    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

  • gary 385 posts 915 karma points
    Feb 20, 2013 @ 13:49
    gary
    0

    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

  • Pinal Bhatt 298 posts 389 karma points
    Mar 31, 2013 @ 16:39
    Pinal Bhatt
    0

    So many responses but still no satisfactory answer. How to get NiceUrl from IContent object for content node?

  • Sebastiaan Janssen 4847 posts 14391 karma points MVP admin hq
    Mar 31, 2013 @ 19:24
    Sebastiaan Janssen
    0

    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:

    @Umbraco.TypedContent(1234).Url

    See the documentation at: http://our.umbraco.org/documentation/Reference/Mvc/querying

     

  • Randy McCluer 59 posts 87 karma points
    May 08, 2013 @ 23:19
    Randy McCluer
    0

    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.

  • Charles Afford 1163 posts 1709 karma points
    May 10, 2013 @ 14:40
    Charles Afford
    0

    Is IContent not an interface?

    Gary i am confused as to what the problem is? :).  Charlie.

  • gary 385 posts 915 karma points
    May 17, 2013 @ 00:37
    gary
    0

    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

Please Sign in or register to post replies

Write your reply to:

Draft