Copied to clipboard

Flag this post as spam?

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


  • Mark 122 posts 255 karma points
    Jun 18, 2015 @ 13:33
    Mark
    0

    Get node from URL part

    What is the best way to get a node from a URL part?

    I want to find the node for any given part in a URL, so I don't think I'm after IContentFinder. I need to run this from in a helper class, so just pass in the URL, and get out the node that matches the first part of the URL (I can't use AncestorOf etc. as actually, the node sits outside of main site structure so it can be reused. For example:

    Root
        --Home
            --MultiUseNode
        --Restaraunts
            --Restaurant1
            --Restaurant2
    

    I have been able to build the URL so that I can have: http://example.com/Restaurant1/MultiUseNode/ and loading that content is fine using IContentFinder. However, from my MultiUseNode template, I want to easily find what restaurant is currently being viewed.

    I can manually look it up from a class using the URL, but then am I not getting any caching goodness like I would in IContentFinder?

    Any thoughts would be appreciated.

    (trying to keep structure simple for editors, so had thought of auto-creating MultiUseNodes under each restaurant, but as you're all aware, keeping it simple for one person makes it more complicated for others, i.e. me!)

    Mark

Please Sign in or register to post replies

Write your reply to:

Draft