Using data/blocks on pages in Umbraco - umbraco

I am new to Umbraco and was wondering what is the best approach to organize content structure to include pieces of dynamicly added blocks on a site. Let's say I have services section on my home page, and there are service item blocks which are dynamicly added/deleted by the content editor through the backoffice. So where do I actually create this services folder, and service items? It must be also taken into consideration that I am developing multilanguage website.
The question is pretty much similiar to this one in the umbraco-forum , but because I develop for multilang, I find it inconvienet to create any other nodes (for settings or these blocks) on the root level, because they will have to be copied to other languages.
So far I think of three ways to do this:
Create services and service item document types, and include them under the Home page node. The disadvantage of this approch is the confusion between "real pages" and this kind of blocks. (though the workaround could be prefixing the name of "data/block" folder with underscore sign, e.g. "_Services")
Create differents folders for "Pages" and for "Blocks" under under Home page node. Then I could use Url rewriting to overcome extra part which are added in the paths for pages. (so for example map "/pages/about-us" to "/about-us"
Use media types for this kind of blocks. About this I am not sure at all, because I see no option to copy items for other languages as it is done in document types.

The Umbraco resource refers to canvas, which is a feature that allows a content editor to modify content on a page in a WYSIWYG editor style. Canvas is unreliable & has been disowned as buggy & not to be used even on the Umbraco training courses.
You could build a back-office function in a custom datatype (http://umbraco.com/help-and-support/video-tutorials/developing-with-umbraco/data-editors/creating-a-custom-datatype-using-the-usercontrol-wrapper) that mimicked a WYSIWYG editor, but I don't think one currently exists.
The usually pattern when you want blocks of functionality in Umbraco is to use macros. Macro are maintained under the developer section, rather than the content section.
You could also use base extensions (http://our.umbraco.org/wiki/reference/umbraco-base) for dyanmically generated blocks that use Umbraco data.
Whether using a macro or /base you could use some hide/show fields in the affected doc types to show or hide specific blocks on specific pages.

Related

Create a non-content page in Umbraco

I have a query regarding how to create a bespoke page that doesn't warrant having any document type or content associated with it.
For example there could be several pages on a site that are so different to each other that they would effectively have to have their own template.
How does Umbraco handle cases such as these, were one would effectively have to create a NON-content page with no fields in it, and then have multiple templates for each page associated with a NON-content page or am I missing the point?
Surely not every case deserves place-holders with fields in it?
If you want to add static pages, it's probably the easiest to create an empty document type and create multiple templates for this (as you stated in the opening post). This way you're still using the Umbraco routing but can't edit any content.
Another way (depending on the technical expertise of the content editor) could be to create a document type with a html editor (I believe some 3rd party packages exist) where you can paste in the html for the page. This is less user friendly (from the view of a content editor) but you don't have to create separate templates for each page.
Sounds like you want to use "Route Hijacking".
See the Link below or Google "Umbraco Route Hijacking" for details.
http://www.jondjones.com/learn-umbraco-cms/umbraco-developers-guide/umbraco-core-concepts/what-is-route-hijacking-in-umbraco

Front end page urls

I have an umbraco installation.
I published a content named "Account" and umbraco gave it this url /account.
Fair.
Then I published a content named "Register" under content Account (I allowed Account Doc Type to have Register Doc Type as child).
I would expect the url of the new content to be /account/register, but umbrace gave it /register.
Why is this happening? What's the point of allowing child content types, and building a content tree, if the urls are all from root? As a newbie to umbraco, I consider it a logic flaw. For a CMS that claims to be friendly, that's not friendly at all. I'm a developer but I can't waste half of my day looking for umbraco answers and tutorials online. A friendly CMS should be self explicatory while being used, and should take care of all common assumptions a newbie may have.
How can I make the Account->Register content node to appear in /account/register url?
I think what you're seeing is a side-effect of a feature in Umbraco that is supposed to support the pattern most develops use when creating an Umbraco website.
The best practice when building Umbraco websites is to create a "Website/Root/Site" document type and place this in the root of your hierarchical content structure. Beneath this document type you place each of your pages as direct children. This allows you to set hostnames and culture on your site as well as it allows you to keep your entire site in one "bundle", and it also allows you to do multiple subsites within the same Umbraco website. It is pretty common practice to structure your website this way.
However - as you expect - this would give your URLs such as domain.com/website/account/register due to Website now being an actual content node in Umbraco. As this is really not something anyone would want - Umbraco has a built-in feature allowing the top level node to be hidden from the URL path. This results in your URLs being domain.com/account/register in this case.
If you however consider your site - this feature results in your register page getting the URL: /register since the /account part is a top level node that will be ignored when generating URLs.
This behavior is triggered by the setting umbracoHideTopLevelNodeFromPath which can be found in web.config of your site (true by default).
I would however recommend that you do not change this setting and instead add in the root node for your site as it will make things easier for you to manage in the future - it is also the best practice way to structure a site.
This should result in URLs being generated the way you are expecting them to be. Child nodes will have URLs that reflect their name and location in the content tree.

Battle-hardened strategy for naming files and folders in asp.net mvc projects

In French, a "donkey bridge" is some apparent difficulty in a subject to be learnt that throws off newcomers - the donkeys. The expression is used with patronizing assurance by educators who know the difficulty is apparent, not real, and the donkeys just have to cross the bridge.
Well I'm the donkey, and I'm having real trouble settling down with the folder structure and "virtual" urls of asp.net mvc projects. Urls are now a blend of pseudo-path information, encoded in routes, and arguments, that resolve to controller classes that, being classes, have no notion of their directory. So, it seems, there is no simple way of using relative paths/urls to reference static resources associated with a dynamic page: script file, stylesheet, razor view, images. .Net helpfully gives me default search locations for views, and default folders for "Content", "Scripts", "Images". I get the feeling they want me to file things by type. But this obliges me to invent file and subfolder names in each of these locations, then to hardcode the resulting paths in the controller and the view. Since a given controller generally has only a handful of tightly coupled views, and 99.9% of views have 1 script file and 1 stylesheet, all this name invention, and categorization by type, introduces needless brittleness and complexity, and masks any expression of what the project actually does.
Is anyone else fighting this? Is their a tried-and-tested strategy for naming in large mvc projects that
Expresses what the project does at the top level of the folder structure (or any level of the folder structure!).
Provides a default location or generated names for .cshtml, .js and .css, such that I don't need to search through code to find the names of associated resources.
Preserves the flexibility and decoupling of naming/indirection where this has proved useful.
I'm aware of areas as a way subdividing an mvc project into functional groupings, but this just seems to recreate the problem inside each area. I've looked at this method for customizing the search location for views, but there's no dynamic element. I've implemented a view engine to have fine-grained run-time control over the view path, which is fine if you're brave but I'm still unsure how best to use it, and I'm put off by the potential caching issues. For all the dissing of opinions, I'm particularly interested in answers addressing what I should do.
Thanks to all the downvoters, intolerant village folk. The donkeys that refused to cross the bridge are right, and they're all hanging out in a green field, munching happily on Nancy and building fabulous Owin pipelines. Feature folders are the future.
I agree with you that trying to arrange elements by type is usually problematic. For example putting C# interfaces for a customer and a product in the same "Interfaces" folder is not something I am keen on personally, I'd rather have a Customers folder and a Products folder, each with an Interfaces folder inside.
However, with MVC, there is a lot of enforced and unenforced convention in place which you will probably have to live with. As an example, if you have a controller called ProductContoller, it will automatically look for views in the Views\Product folder. So your product index.aspx/cshtml view is nicely segmented from your other index views.
For things like scripts and CSS, these are not enforced and technically you could put them anywhere, but it's a convention across many web frameworks to keep them in the same root folder. In some frameworks you would be explicitly allowing public access to certain folders to read files, so you'd want to do this for all scripts or CSS files together.
It's not an answer but I hope it helps.
then to hardcode the resulting paths in the controller and the view
No.
Use UrlHelper (Url property in controllers and views). Extends it with ad-hoc functions for resolving your specific urls, as this blog post do.
For resolving views, stick to MVC conventions as explained in Dorian's answer.

microsite in umbraco

I am relatively new to umbraco and have just got the site build but the clients request for a microsite with a completely new look and feel.
So how do I set up a new microsite in umbraco.
Please Help.
Thanks a ton
To give pages within Umbraco a completely different look and feel from the others, there's a few different ways you can go. Obviously there's more than one way to solve a problem, but I'll just mention a few that I can think of and explain how they'd work.
Create a new master page template that has your new design, then create child templates for each document type, to include a home page, a standard text page and anything else you may need. Assign these templates to the document types that will use them.
Pros: Easiest approach. Allows most flexibility in design.
Cons: The user can choose the wrong template or forget to set the right template.
Create separate templates as in option 1, but also create separate document types. Assign the templates only to the new document types. Each document type can extend your existing ones to inherit the same properties or you can create entirely new ones.
Pros: Ensures that the uses uses the correct template all the time. Allows most flexibility in design. Allows site specific customization - can add or remove properties.
Cons: The number of document types doubles and therefore the amount that appears for the user to select. Of course the number that they see can be limited by what templates they are allowed to create.
Use existing templates, but include a check that determines which site is being visited, depending on the path or subdomain, etc., then dynamically load different style sheets.
Pros: You do not need to create separate templates or document types for the microsite.
Cons: Your master template's markup will have to be generic enough to compensate for both designs, therefore it isn't as flexible.
Once you choose an option for how you will structure and style the pages of the microsite (and remember that my list is not conclusive), you will need to determine where to setup the node structure. The best option here, if the microsite will be subdomain or if it has its own domain, would be to add it as a separate home node first and then add all of its own pages below it. Then you can actually setup a different host reference for the site within Umbraco. There have been a few answers on SO that mention how to do that:
Assigning hostnames in umbraco
Publishing multiple sites on a single instance of umbraco
Here are some basic steps to allow Umbraco to use other domain names:
Setup your web server to accept host headers for the specific domain/subdomain. In IIS 7.5, this can be done by adding bindings for the domain/subdomain.
The new node needs to be a direct child of the Content node.
Right-click the node and choose "Manage hostnames". Then add the domain/subdomain URL.
Hope that helps! Feel free to ask more questions.

Having trouble implementing multilingual umbraco 3.0

How to implement the multilingual umbraco 3.0?
There are two different approaches to this.
The documentation on the Umbraco website describes how to do 1:1 multingual sites. This means that you have one site structure and different language tabs in a single document type for each translation od the content. This is then selected by using an on page selector on the website (a flag icon or the like).
Here's an example of a 1:1 site
This is the most efficient set up if you have lots of shared content i.e. the content and structure is exactly the same, the language is just different.
The second approach is to use separate page structures for each language, such as:
International Homepage
------> English Homepage
------------> English content page
------> French Homepage
------------> French content page
The advantage of this structure is that it is very easy to set up, but if you share lots of content it can be cumbersome to manage. It also has the advantage that you can lock the editing permissions down for country/language specific editors.
With the above structure you can also point individual URLs to the country pages.
Without knowing more about what exactly your requirements are it's hard to answer more fully as to which is the best approach. It may also be possible to create a hybrid solution.
Here are some links which may help:
http://forum.umbraco.org/yaf_postst2209_Multilingual-structure-in-umbraco.aspx
http://www.nibble.be/?p=32

Resources