Copied to clipboard

Flag this post as spam?

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


  • Tom van Enckevort 107 posts 429 karma points
    Apr 13, 2017 @ 11:12
    Tom van Enckevort
    0

    Use different parent node with ContentFinder

    So I have a multi-site setup with different sites (each with their own domain name) and a bunch of nodes that get shared across those sites:

    • Site 1
      • Listing
    • Site 2
      • Listing
    • Site 3

      • Listing
    • Shared Content

      • Node A
      • Node B

    I'm using a UrlProvider and ContentFinder implementation to assign the URLs to Node A and Node B for Site 1, 2 & 3. This works fine and I can see the assigned URLs in the CMS and when I go to http://site1.example.com/listing/node-a it will load the correct node through the ContentFinder.

    But the problem I have now is that to render things like the navigation/header/footer on that page I need to get the root site node. Normally I could do Model.AncestorOrSelf(1) (or Model.Site() in v7.5+) to get the site root node, but in this case it will get me the root node of the Node A content node (which is Shared Content).

    What is the best way to get round this?

    Can I somehow 'override' the parent node inside the ContentFinder when it assigns the IPublishedContent to the PublishedContentRequest?

    Or would I need to get the virtual parent node (Listing in Site 1) by parsing the request URL and getting that node via the URL name instead?

  • Jamie Pollock 174 posts 853 karma points c-trib
    Apr 13, 2017 @ 11:23
    Jamie Pollock
    100

    Hey Tom,
    Would something like this help?

    https://our.umbraco.org/forum/using-umbraco-and-getting-started/85100-running-multiple-sites-single-installation-with-a-fall-back-default-site#comment-269539

    If you scroll down to three bottom there is some code regards finding the correct site root of the publishedContentRequest is different from the domain root.

    Thanks,
    Jamie

  • Tom van Enckevort 107 posts 429 karma points
    Apr 13, 2017 @ 12:19
    Tom van Enckevort
    1

    Thanks Jamie, that thread does contain a few pointers I can play around with.

Please Sign in or register to post replies

Write your reply to:

Draft