I've started working with Umbraco yesterday and my vision of working with it was as follows:
add document types
create a basic content tree
create templates
edit document types & templates adding what I need and replacing "lorem ipsum" with the content from Umbraco
The problem is that I added two properties to a Client document type. Then I got this while trying to edit content:
Object reference not set to an instance of an object.
This is hard to understand for me, because:
Umbraco is supposed to be friendly ('the friendliest...')
Database structure is organized in a way that this should not be the problem
Even using Fluent NHibernate Migrator adding a field to a database just creates another field without throwing any exceptions - and here?
So what's the idea here? Document types are once and for all and you can't edit them?
First of all it would be helpful to know which version of Umbraco you are using as there are minor differences in the versions 4.x and now with v5 it's a completely different game with a complete new codebase on ASP.NET MVC.
In some versions of v4 there had been a bug where you get the error message you posted when you have added two document types with the same alias or two properties with the same alias to one document type.
So that you cannot edit the content is not the intention of umbraco ;-)
Related
I've got an Umbraco site in Visual Studio that uses the generated Umbraco.Web.PublishedContentModels.dll for its models.
I'm trying to update this site from 7.5.6 to the latest version of Umbraco 7 (7.15.5). Along with the updated Umbraco CMS Nuget package, I get the updated Umbraco.ModelsBuilder 3.0.10.
Everything seems OK, but when I try to regenerate the Umbraco.Web.PublishedContentModels.dll through the backend, the generated DLL has different property types for certain models.
Mostly it's properties that used to be strings, that are now IPublishedContent. For instance, I've got a Document Type "Meal" that has a Media field "Photo". Photo used to be a string, but it's now Umbraco.Core.Models.IPublishedContent.
I inherited this site recently, so I'm not really sure how the type of the Photo property was generated as string to begin with. Has there been a change between 7.5 and 7.15 in how models are generated? Or was some configuration broken?
I guess I can rewrite each place where these properties are used to unwrap the IPublishedContent and get the right property out, but it'd be a lot of work that I would rather avoid.
Umbraco team added value converters to all built-in data types in v7.6.
Value converters can be disabled in ~/config/umbracoSettings.config:
<!-- Enables value converters for all built in property editors so that they return strongly typed object, recommended for use with Models Builder -->
<EnablePropertyValueConverters>true</EnablePropertyValueConverters>
You can find more details here:
https://issues.umbraco.org/issue/U4-7318
Exploring Umbraco 8 and playing around building a test site etc.
Building document types and content pages via the back office interface, and looking in the code itself I've noticed a files called models.generated.cs.
looking inside, it contains partial classes like public partial class AndyTestPage : PublishedContentModel { } and properties I've given it like
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder", "8.5.5")]
[ImplementPropertyType("andyProperty1")]
public string AndyProperty1 => this.Value<string>("andyProperty1");
my question is, what exactly is the point of this file? what does is do and how are these properties and classes created in here via the backoffice cms.
second question is, how would I go about creating a document type, and properties from code? my noob assumption is to simply add the classes in the this file, but that doesnt seem right?
Thanks,
Andy
It belongs to modelbuilder.
It depends on how you build your umbraco solution. If you use visual studio you can use something called strongly type, it helps building templates with VS.
By default, modelsbuilder is set to "PureLive", which is for users who builds within the umbraco backoffice system.
You can set modelsbuilder to different options, depending on how you build.
You should not edit the file, it is created and maintained by the system.
https://umbraco.tv/videos/umbraco-v7/implementor/working-with-umbraco-data/working-with-models-builder/
https://our.umbraco.com/documentation/reference/templating/modelsbuilder/
elitenet.dk has answered the first question
With regards to your second question Umbraco is database/content first so unfortunately you cant write documenttypes etc. from code first... not that i know of.
I beleive this is because Umbraco was designed to be used by almost anyone with a little html/css knowledge. E.g. You can create templates and views from the cms without having to know anything about serverside development.
Just a little tip if youre starting with Umbraco and plan on using multiple environments take a look at Kevin Jumps Usync package, essentually the package allows for document types/properties etc. to be pushed from environment to environment.Usync
I am working on, what I would consider to be, a large ASP.NET MVC website. Currently there are nearly 100 editor templates (all for 1 controller), and this number will grow.
What I want to accomplish is organize my views to make them easier to find and version. This 'version' step is what will make the views multiply as time goes on. you can think of this project as an Question/Answer application, where Exams are created, and can be pulled up later. Basically, for this particular project, the views/EditorTemplates can't really change once in production, so a new copy must be created for future use. References to the old view would still exist, making that exam look and behave the way it did a year ago. Likewise, new exams will automatically pick up the new version of the view, and use that version.
I would like to have this type of structure, but I am up for other ideas.
Views/Shared/EditorTemplates/Common
Views/Shared/EditorTemplates/Common/v2
Views/Shared/EditorTemplates/Common/v3
Views/Shared/EditorTemplates/Department
Views/Shared/EditorTemplates/Department/v2
Note: Even though I will have versioned subdirectories, which implies that I will have multiple versions of the same model and template, the new files will have a unique file name. Also, I am also attempting to use the Razor Generator to compile my views. Not sure if that can be extended to add the additional EditorTemplate search paths or not.
The framework won't look there, use local EditorTemplate folders instead, e.g. Views/Department/EditorTemplates.
Editor templates are located by the view engine, which first looks in ~/Views/{1}/{0}.cshtml and then in ~/Views/Shared/{0}.cshtml.
For example, if the controller is Department and the model is a String, the framework asks for EditorTemplates/String, and the view engine looks in ~/Views/Department/EditorTemplates/String.cshtml and ~/Views/Shared/EditorTemplates/String.cshtml.
Max's answer is a much more elegant and simple answer. If you don't want to do that AND you want a ton of work, you can write your own ViewEngine.
I am new to Umbraco Mvc. A page consists of repeating content -heading and body text. User can be able to add or remove any number of such type of content panel.
How can i implement this?
For this page i added a document type, template and content. I am not sure what to do next?
Please help,
Thanks.
This is an old question but I thought I'd leave a note here.
Umbraco 7
Both Nested Content and Archetype are both great packages for creating repeating content on a page/node in Umbraco. Nested Content is actually so good, as of version 7.7.0, it is included in Umbraco!
Another way to create repeating content is to create the content as nodes/pages in Umbraco, then picking it (using a multinode picker) node/page where you want the data to show.
Umbraco 6
Checkout uComponents as it allows for repeating content too.
Self promotion
My old blog post The best Umbraco packages of 2017 contains a little more information about these specific packages.
I am looking to develop a custom user section in admin panel of umbraco 6.
This section can manage user details as well as admin approval. Any one know how to implement this?
Apparently it is similar to doing it in Umbraco 4
But in Umbraco 6, instead of making the change to the umbracoApp table, you do the change in Config/applications.config file
Update:
For the tree nodes, I am still doing it the old way. Apparently in Umbraco 6 you can use trees.config, but I haven't tried it yet, I don't know much about it.
I have written a blog post about this that should work in Umbraco 6.
The changes that have been made is that instead of changing in the tables you change in the config files. It is also possible to create the tables by code in C# combined with c# attributes.
http://marcus-abrahamsson.se/post/Custom-Section-in-Umbraco-Back-office