Im on a view (the category one). How do I access umbraco fields from here? Ive tried all teh usual Model.AsDynamic and Umbraco.Field etc.. I just need to access content :'(
Yeah Ive tried all the normal ways. Ive drilled down in to the model, and everything I can find but cant access teh data. I think its because its using the Merchello model UmbracoViewTemplate<MerchelloModel>() and thats not allowing access.
The only way I can think is to create my own view model. Have the merchello model within that and get the umbraco context into my viewmodel. But that seems overkill when I just need to access one boolean value from the content
Ill give this a go in a bit when I get back. In visual studio it doesnt pick up products (shows in red) so I was unable to see anythin gin there when debugging
CS1061: 'Merchello.Web.Models.Ui.Rendering.ProductContentListView' does not contain a definition for 'Content' and no extension method 'Content' accepting a first argument of type 'Merchello.Web.Models.Ui.Rendering.ProductContentListView'
I cant step into the Product object as in VS it gives this error
error CS0103: The name 'Products' does not exist in the current context
Which is rather frustrating.
The only way I can see to access it is with the following
Hey Tony - this sounds like an issue with Models Builder and/or how the reference to the generated model. What setting do you have in the web.config for MB?
It was from a totally standard umbraco install so its LiveModels and model builder is true. Ive not ever really used this as all my previous builds were before they brought this out and just hijacked the controller
I really like models builder, but you have to make sure you understand how you view is setup in relation to your models builder configuration (web.config).
By default it installs with "PureLive" which is great for getting things going quickly. However, I've found this setting can be problematic for the VS IDE intellisense albeit the site will generally render fine.
I usually change it to LiveDll and then finally to Dll as I progress through a project. Changing this means you have to go back and manually press the button to generate the models (in the back office) and then remove the reference in the view(s) to the dynamic models ...
Access page content on Category Page
Im on a view (the category one). How do I access umbraco fields from here? Ive tried all teh usual Model.AsDynamic and Umbraco.Field etc.. I just need to access content :'(
I assume Category is just an Umbraco node? If so, you would get the properties like you would normally?
Yeah Ive tried all the normal ways. Ive drilled down in to the model, and everything I can find but cant access teh data. I think its because its using the Merchello model
UmbracoViewTemplate<MerchelloModel>()
and thats not allowing access.The only way I can think is to create my own view model. Have the merchello model within that and get the umbraco context into my viewmodel. But that seems overkill when I just need to access one boolean value from the content
Ah ok, you are using a starter kit? Is it the old Bazaar?
Sorry, should have said Im using fasttrack. :)
Tony,
The category page in FastTrack is an Umbraco page that has a property on it named "products" which is a custom property type.
This returns an object of type
ProductContentListView : IEnumerable<IProductContent>
IProductContent is IPublishedContent so you should still be able to access properties directly with Umbraco extensions.
Can you post a snippet that you are having trouble with?
Ill give this a go in a bit when I get back. In visual studio it doesnt pick up products (shows in red) so I was unable to see anythin gin there when debugging
That could be the ModelsBuilder (if you're using that) and depending on your setting. I've noticed that in PureLive mode myself.
Im trying
But getting this error
I cant step into the Product object as in VS it gives this error
Which is rather frustrating.
The only way I can see to access it is with the following
Which isnt great as the current page might not be the last content set (Category)
Hey Tony - this sounds like an issue with Models Builder and/or how the reference to the generated model. What setting do you have in the web.config for MB?
It was from a totally standard umbraco install so its LiveModels and model builder is true. Ive not ever really used this as all my previous builds were before they brought this out and just hijacked the controller
I really like models builder, but you have to make sure you understand how you view is setup in relation to your models builder configuration (web.config).
By default it installs with "PureLive" which is great for getting things going quickly. However, I've found this setting can be problematic for the VS IDE intellisense albeit the site will generally render fine.
I usually change it to LiveDll and then finally to Dll as I progress through a project. Changing this means you have to go back and manually press the button to generate the models (in the back office) and then remove the reference in the view(s) to the dynamic models ...
e.g. Change:
to
is working on a reply...