Create a non-content page in Umbraco - 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

Related

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.

How to add an mvc page to umbraco

I have Umbraco 7.5 and I need to know how to create normal MVC pages for adding new data to my site.
Lets say I have a Doctype "Node" in back-office. I want to let some people be able to add/edit some nodes without going through back-office. How can I do it?
I've tried to create add my view and controller (the MVC way), but apparently Umbraco hijacks all routing and my controller won't hit at all.
I've googled the matter (which is hard since I am not looking for Umbraco forms :| )and I've found this. But I prefer not to add my form as a part of other page. I mean, does it make sense to create a page in back office from type "something" and then on its template I do my add/edit form of another type? Seems strange, right?
I appreciate any ideas/ solution to this matter
You have a couple of options here. You can create a physical page for the editor to sit on, and add the editor as a SurfaceController action (basically an MVC Partial with Postback, that is still part of the Umbraco pipeline). Your form can then use the Content Service API to update the details. The advantage of this method is your code will have access to all of the Umbraco methods and templating out of the box. You could also use WebAPI controllers for the form if you want to do it all client side with JS requests.
You could also use route hijacking: https://our.umbraco.org/documentation/reference/routing/custom-controllers this allows you to have your own custom controllers for Umbraco routes, rather than using the default Umbraco ones. This is a bit more work to set up.
Finally, you can also tell Umbraco to ignore certain paths entirely, and you could run your controllers on those paths. The disadvantage here is that as the routes are being ignored by Umbraco, you don't automatically have access to all the useful Umbraco templating etc.
I've used the first method recently, and it works fine. The only caveat is that allowing users to edit nodes will fill up the version table quite quickly if a lot of users are editing a lot of nodes (every time a node is saved, a version is created). If you're going down this route, you may want to investigate something like Unversion: https://our.umbraco.org/projects/website-utilities/unversion/ which helps to keep old versions more manageable in situations like this.

Using data/blocks on pages in 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.

Applying themes and styles in MVC 3.0

I come from ASP.NET Form development and now developing a MVC 3.0 application where when customer logs in she can select her different account from drop down:
The drop down contains:
Honda Car Insurance Account
Home Insurance Account
Ford Car Insurance Account.
When she selects one of the account the landing page changes with her historical details data etc. The application contains 4 more pages which has different contents for each account types.
In ASP.NET Form we could use themes and skins etc to apply the styles on the page based on which account the user has selected. However I don't see this seem to work on MVC.
Could anyone please suggest what would be the best way to achieve above in MVC?
Create one controller for each page and separarate views fro each accounts?
Should each page contentes be served by partial views?
Any other suggests?
NB: The JSON structure sent from controller is unique to each account type as each account have different properties.
Thank you very much for your help.
I would use a separate controller for each section. Then in the View folder for that controller, add a _ViewStart.cshtml file and inside it put
#{
Layout = "~/Views/Honda/_Layout.cshtml";
}
This will point to the layout page for this controller (Honda controller, but use whatever names you want.)
Then in the _Layout files you can add different layouts, css, etc.
That's probably the simplest way to get drastically different looking sections to the same site. Plus you would still have your default Home and Account controllers to keep a standard landing page, etc.
You can still use partial views, and anything else you would like with this setup. It may even mean faster loading time for the end user since their browser won't have to download css and other files that it's not using.
Edit
Here is a bit more information, ASP.NET MVC 3: Layouts with Razor from ScottGu's Blog
Because this code executes at the start of each View, we no longer
need to explicitly set the Layout in any of our individual view files
(except if we wanted to override the default value above).
Important: Because the _ViewStart.cshtml allows us to write code, we
can optionally make our Layout selection logic richer than just a
basic property set. For example: we could vary the Layout template
that we use depending on what type of device is accessing the site –
and have a phone or tablet optimized layout for those devices, and a
desktop optimized layout for PCs/Laptops. Or if we were building a
CMS system or common shared app that is used across multiple customers
we could select different layouts to use depending on the customer (or
their role) when accessing the site.
This enables a lot of UI flexibility. It also allows you to more
easily write view logic once, and avoid repeating it in multiple
places.

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.

Resources