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?
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.
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 3
Shared Content
I'm using a
UrlProvider
andContentFinder
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 theContentFinder
.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)
(orModel.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?
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
Thanks Jamie, that thread does contain a few pointers I can play around with.
is working on a reply...