If I have 1 Umbraco installation with 4 websites, is it possible to share contents between the sites?
Or is it better to create another website ('repository') that will have all the contents and allow the 4 other websites to retrieve/link contents from this 'repository' website?
There was a good session at Umbraco CodeGarden by CountryWide this year that might be worth watching as it discussed a group in the housing market that have about "40+ different high traffic sites from a single Umbraco installation" but with shared content between many of the sites in the group. You can watch the video here:
http://stream.umbraco.org/video/9921509/40-different-high-traffic-sites-from-a
I'd recommend watching the entire video but if not you can jump to about 25 minutes in to see this topic of discussion. They have a shared content node (+ children).
Simon
I would recommend you stick with your existing websites and not create a repository website. This makes it easier I think to define canonical urls for documents if they are to be displayed on multiple websites. Also makes more sens from a content editor point of view. To reach content from another website, I would use code similar to this (considering Umbraco 7+ here):
// Root nodes
var root = Umbraco.TypedContentAtRoot().First();
var site = Model.Content.AncestorOrSelf("Site");
var lang = Model.Content.AncestorOrSelf("LanguageHome");
var allOtherWebsites = root.Children.Where(x => x.Id != site.Id);
var newsFromAllOtherWebsites = allOtherWebsites.Descendants("News").Where(x => x.Parent.Name.ToLowerInvariant() == lang.Name.ToLowerInvariant());
// Do things with news...
I threw in something for multi-lingual setup also, you can simply remove those if you don't need.
Hope this helps!
Related
I want to create a multilanguage site in contao.
What I did so far:
At first I copied the Page tree of current language.
At second I added domains like example.com/de and example.com/en in site-structure "Domain name" of both root pages.
Edit: Finally I added app/config/config.yml
contao:
prepend_locale: true
For my assumption it should work now but it doesnt.
What else is necessary to make it work.
In your case you do not configure any DNS names for your website roots, since you are using only one domain. Instead, you should use the following in your app/config/config.yml:
contao:
prepend_locale: true
Clear and warmup the production cache afterwards. This will generate URLs like example.com/de/… and example.com/en/….
See also https://github.com/contao/core-bundle#configuration
I have a problem to make a decision for putting Category/Path on URL Routing. Assume I have some products in my sample Web Application those attached to some categories. For example:
Book1 Attached to -> Category1 | Category2
Book2 Attached to -> Category1 | Category2 | Category3
Book3 Attached to -> Category2 | Category3
And defined routing map for products is:
url: "{controller}/{action}/{languageCode}/{category}/{product}"
defaults: new { controller = "Home", action = "ViewItem" }
So possible routing for Book1 are:
[Domain Name]/Home/ViewItem/en-US/Category1/Book1
[Domain Name]/Home/ViewItem/en-US/Category2/Book1
And possible routing for Book2 are:
[Domain Name]/Home/ViewItem/en-US/Category1/Book2
[Domain Name]/Home/ViewItem/en-US/Category2/Book2
[Domain Name]/Home/ViewItem/en-US/Category3/Book2
I want to save and know current category but have single unique URL for each product(For search engine tracking and sharing URLs purpose). I think about using Session Variable or ViewBag even Cookie, But each of them has own limitations and cons. For example using cookies may cause some troubles: if set expiration time too small, it may lost current path when user pausing on some pages and if set it too long, may lead user to old browsing path even user requested for home page in new opening browser because of existing cookie (Except that, I'v some experiences with cookies and I believe that is not working precisely all times), About Session and ViewBag I don't know if using them is the best idea, So can anyone share tested solution or good idea? I will appreciate that.
You should have the page mywebsite.com/product1 (the canonical version of the URL). Including all the versions of the URL won't help. Likely, it will just confuse Google and may lead to Google ignoring certain URLs
Even if you put in the canonical version and have the rel canonical tag on your pages, Google may still choose to treat another version of the URL as canonical.
Ideally, then, I'd solve the real problem here and just have one version of the product URL on your site (have the versions with the category in the URL redirect to the version of the URL with no category in the URL). That way you don't even have to worry about all the issues duplicate content may cause.
I suspect this isn’t a routing problem, rather an architectural issue. I think that the “language code” and “category” should be an attribute of the Book object, rather than being a part of the route.
You would then have URLs like:
{domain}/{controller}/book/id
And for “category” specific or “language code” specific views, you could have URLs like:
{domain}/{controller}/search?languageCode=enUS&category=1
This would still be perfectly RESTful and in my opinion, much simpler as well.
With reference to the documentation 'Controlling URL behavior', I have multiple sites and the logical structure has some of the nodes from one site under another.
So I have a sitemap in each site which represents this. When running in debug, it works fine and the breadcrumb links are ok - using the controller/action/preservedRouteParameters/hostName. BUT when deployed to the live site, an extra part is added to the link.
e.g. In DEBUG - From site 2 (localhost:1234) a link will resolve to 'site1(localhost:5678)/Controller/Action/PreservedRouteParameter
Where as In RELEASE - From site 2 (www.site2.com/events) a link will resolve to 'site1(www.site1.com)/**events/**Controller/Action/PreservedRouteParameter
so my question - is there a solution to my problem (having the extra events in there?
WORK AROUND
I couldn't figure this one out. I did however come up with a way around this....
Create a new controller (or use existing)
Use redirect:
public ActionResult myRedirectAction(int id)
{
return Redirect("http:localhost:1234/Controller/myAction/" + id);
}
How do you get the root home node of the current site in an Umbraco 6 Multi site install?
The structure is this:
Content
--Home1
--About
--Contact
--Home2
--About
--Contact
--Home3
--About
--Contact
var root = Model.Content.AncestorOrSelf("[YourHomeNodeDocumentType]");
I'm not sure if this is Umbraco 6 syntax, but what you want is that AncestorOrSelf traveersing call. I have many multi-site-multi-lingual setups and I use that all the time. The "or self" portion is fun, in some cases that "root" node is a page.
This works a treat
var rootId = (CurrentPage.Path.Split(','))[1];
It depends if you want a Dynamic Object or a strongly typed DynamicNode Object - but I tend to be in favour of doing it the strongly typed way so I rely on
var root = CurrentModel.AncestorOrSelf(1);
Depending on the version of Umbraco 6 you could use
IPublishedContent rootNode = Umbraco.TypedContentAtRoot().FirstOrDefault();
for a site with a single root node or
IEnumerable<IPublishedContent> rootNode = Umbraco.TypedContentAtRoot();
for as site with multiple root nodes as in your case. These will both work for versions closer to the version 7 track.
I typically use:
Model.Content.AncestorOrSelf(1);
or
IPublishedContent topNode = Model.Content.AncestorOrSelf(1);
I am fairly new to Umbraco and I am wondering where I should put pieces of random data.
I have a lot of experience with Sitecore, used it for several years, I am certified etc etc. But now I have to build something with Umbraco. At a first glance Umbraco looks inferior to Sitecore in every way, but I might be wrong about that.
So what I am wondering is, where should I put non-browsable pieces of data that are visible on several places throughout the website? I'd like to create data items in Umbraco for things like Testimonials, Offices? I'd like to have a centralized place in Umbraco where they can be maintained and reference them from a page node. But the way it looks now is that everything has to be on the page node. Which is sort ok, for your average family webpage.
Could someone please shed some light on this?
You could create another node under the man content and call it site settings and store them there that way all pages under the home page are just visible pages on the front end and all data nodes are in a separate area.
There is one property in umbraco that you can add to document types and name it "umbracoNaviHide" (for alias, the name can be anything). This allows wires in automatically to the .IsVisible() method.
var children = Model.Content.Children.Where(x => x.IsVisible());
I find this situation to be very frequent, think of slideshows. When I make an Umbraco website, under my root node I normalle havea Slideshow document type (that contains slides) and I programmatically traverse those to build the slideshow on the home page for example. This Slideshow document has that "umbracoNaviHide" property and I skip it from my menus either using the .IsVisible() method or by manually skipping specific document types.
var menuItems = Model.Content.Children.Where(x => x.DocumentTypeAlias != "Slideshow" && x.DocumentTypeAlias != "Search");
On the other hand, if you are looking for "labels", you can look at "Dictionnary" items under the "Settings" tab.
To directly answer your questions, I reccomend putting non-browsable pieces of data as children of the relevant browsable content node. (But there are other valid ways to do this, it really is up to you and what's best for your content editors.)
Hope this helps.