Copied to clipboard

Flag this post as spam?

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


  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 8x admin c-trib
    Jul 12, 2016 @ 09:13
    Chriztian Steinmeier
    0

    How to handle hostname with path step in a ContentFinder?

    Hi,

    I'm writing a ContentFinder for some calendar content that has URLs like this:

    http://domain.io/calendar/2016/07/12/now-were-talkin/
    http://domain.io/da/calendar/2016/07/12/saa-koerer-det/
    

    The first one has its hostname set to domain.io while the second one is set to domain.io/da

    What's the sensible way to get the path after the domain name, in the ContentFinder's TryFindContent() method?

    If I use the Uri.GetAbsolutePathDecoded() method, it's including the /da/ part that's part of the domain (Umbraco-wise, at least).

    Thanks,

    /Chriztian

  • Morten Bock 1867 posts 2140 karma points MVP 2x admin c-trib
    Jul 12, 2016 @ 09:51
    Morten Bock
    1

    My approach would be something like this.

    Given that the first part of the path would actually resolve to a node, you could ask the base/default contentfinder to get that for you. So make a loop where you remove segments on by one:

    Now you have your base node. Then you trim that part of the url, from the inbound request url, leaving you with "2016/07/12/saa-koerer-det/". And then I guess you can find the actual node you want based on whatever logic you need?

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 8x admin c-trib
    Jul 12, 2016 @ 09:59
    Chriztian Steinmeier
    0

    Thanks Morten - that seems like a neat way of doing it.

    (And of course - now I'm suddenly thinking that what I'm actually going to need, is a rewrite rule... :-)

    I'll give this a shot, nevertheless - thanks!

    /Chriztian

  • Morten Bock 1867 posts 2140 karma points MVP 2x admin c-trib
    Jul 12, 2016 @ 10:39
    Morten Bock
    1

    Well, with the rewrite rule, you will have to know that the "calendar" node is never renamed/moved, or have some sort of uniquely identifiable way of knowing when to remove the date part of the url.

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 8x admin c-trib
    Jul 12, 2016 @ 12:30
    Chriztian Steinmeier
    0

    You're right - very good point!

    (Not that clients ever rename pages or — God forbid — move stuff around! 😱)

Please Sign in or register to post replies

Write your reply to:

Draft