Hello guys, finally registered after searching for a few days without achieving any results. So .. fairly new with Umbraco (also fairly new to programming) and I'm having a problem with traversing child nodes of a document type and getting the "cannot bind source content type umbraco..." error. I want to use strongly typed content using "UmbracoViewPage" (using Dll Models Builder)
But Bojko show us some code. Right away kind sir.
So I have a document type "News Archive" which is having regular stuff: Title, Body Text. Not much.
And a document type News Article, which is a child node of 'News archive'.
what I want to do is list all 'news articles' in the news archive page, regular stuff.
So i'm accessing the collection of articles
"var articles = Model.Site().FirstChild("newsArchive").Children("newsArticle").Where(x => x.IsVisible());"
and now I can foreach them
@foreach (var article in articles)
and now to the question, is there any way to use some intellisense
article.articleTitle
article.articleBodyText .. etc..
Right now I'm using @article.GetPropertyValue("alias"), but I'm not feeling happy about myself using magic strings.
and if i type
@inherits UmbracoViewPage
p.s. cheers from Bulgaria.
p.s2. if any - sorry for grammar and spelling errors.
For others & in case you couldn't get any further:
in web.config change PureLive to LiveDll, recompile.
In the Umbraco backoffice go to the developer section, open the modelsbuilder tab and click the Generate Models button.
Back in your project you should be able to use the models from the publishedcontent where UmbracoHelper is being used, but I prefer to reference the Umbraco.Web.PublishedContentModels.dll in the Bin folder of the project that way I can use them easily anywhere within the program without using all the Umbraco overhead if it is not needed.
Now, if anyone reads this, do you know how to get an equivalent function to Umbraco.TypedContentAtRoot() ?
Intellisense using strongly typed models
Hello guys, finally registered after searching for a few days without achieving any results. So .. fairly new with Umbraco (also fairly new to programming) and I'm having a problem with traversing child nodes of a document type and getting the "cannot bind source content type umbraco..." error. I want to use strongly typed content using "UmbracoViewPage" (using Dll Models Builder) But Bojko show us some code. Right away kind sir.
So I have a document type "News Archive" which is having regular stuff: Title, Body Text. Not much. And a document type News Article, which is a child node of 'News archive'. what I want to do is list all 'news articles' in the news archive page, regular stuff. So i'm accessing the collection of articles "var articles = Model.Site().FirstChild("newsArchive").Children("newsArticle").Where(x => x.IsVisible());"
and now I can foreach them @foreach (var article in articles)
and now to the question, is there any way to use some intellisense article.articleTitle article.articleBodyText .. etc.. Right now I'm using @article.GetPropertyValue("alias"), but I'm not feeling happy about myself using magic strings. and if i type @inherits UmbracoViewPage
p.s. cheers from Bulgaria. p.s2. if any - sorry for grammar and spelling errors.
Have you had a look at this: https://24days.in/umbraco-cms/2016/getting-started-with-modelsbuilder/
For others & in case you couldn't get any further:
PureLive
toLiveDll
, recompile.Now, if anyone reads this, do you know how to get an equivalent function to
Umbraco.TypedContentAtRoot()
?is working on a reply...