"The Umbraco Helper is just that, a helper that you can call on to retrieve things from Umbraco, to perform tasks like Searching the content index, rendering Macros, stripping HTML from text, finding out if a content item is protected etc. Generally useful and commonly used tasks that would otherwise take you a long time to build yourself.
To access the helper in your Views is easy. Just use @Umbraco. If you are working in Visual Studio and you you will get Intellisense and it will allow you explore all of its options. "
Its strange because the @usingUmbraco.Web Should be automatic since it is included in the namespaces references in the web.config for razor views at ~/Views/web.config
But yeah, i'll include them in examples when i write them.
IsVisible() is a shortcut to having a property on your documents called 'umbracoNaviHide' which is a true/false property. This is common practice in umbraco that dates way back to when guys wore neon clothes and really tight pants (oh wait, that happens now too :P ). It's just a flag to determine if a document should show up on the front-end or not even if it is published, for example in a menu or other list when iterating over children.
I think you'll need to include the namespace:
@usingUmbraco.Core
as well, but again its strange because these should be automatically resolved based on the web.config.
MacroScripts will be deprecated in 6+ though we will support them for a while. The replacement is Partial View Macros which use the exact same syntax and object as MVC views. So in 6+, you will be able to use strongly typed goodness with Partial View Macros.
Shannon - thanks for the info, that explains why I knew about that namespace :) I had Views/web.config exclude in my VS solution. After including it, everything works automatically.
Martin - perhaps this is your problem too? I can confirm you shouldn't need to add that first namespace.
the ~/Views/web.config should get created automatically if it is not there by our view engine. It is required for MVC to work properly. If it is not there, you'll probably end up with problems :)
Extension methods on strongly typed Razor in VS2012
Hi Shannon
How on earth do I get the extension methods for strongly typed razor like in the example below???
I just keep getting the error...no definition or extension method are you missing an assembly reference?
Martin
Hi Martin,
If you are using MVC in 4.10 or above -
"The Umbraco Helper is just that, a helper that you can call on to retrieve things from Umbraco, to perform tasks like Searching the content index, rendering Macros, stripping HTML from text, finding out if a content item is protected etc. Generally useful and commonly used tasks that would otherwise take you a long time to build yourself.
To access the helper in your Views is easy. Just use @Umbraco. If you are working in Visual Studio and you you will get Intellisense and it will allow you explore all of its options. "
The above quote came from here ; http://umbraco.com/follow-us/blog-archive/2012/10/30/getting-started-with-mvc-in-umbraco-410.aspx
or, there is more here; http://our.umbraco.org/documentation/Reference/Mvc/
If you are using the webforms version, it does explain you will not get intellisense with the dynamic. (Sorry, only use the MVC version).
Hope this hellps you move in the right direction.
Regards
Gary
Hi Martin,
Try adding this using statement to your .cshtml file:
Ex:
Hope this helps,
Tom
Hi Tom
That did it!
The umbraco.dll is changing so rapidly, its damn hard to keep up!
Shannon, when examples are published on our.umbraco or your own blogsite can you always make sure you include the namespace references?
Now to re-write all of my XSLT and user controls as MVC/Razor! Hurrah!
Thanks all
Martin
Hi all
I still have an issue with one of the examples....
IsVisible 'Does not take one arguments'
What is IsVisible anyway??? Is it published/unplublished of some other property (of which i've not seen in the umbraco back office)
Thanks
Martin
@Martin,
Its strange because the @usingUmbraco.Web Should be automatic since it is included in the namespaces references in the web.config for razor views at ~/Views/web.config
But yeah, i'll include them in examples when i write them.
IsVisible() is a shortcut to having a property on your documents called 'umbracoNaviHide' which is a true/false property. This is common practice in umbraco that dates way back to when guys wore neon clothes and really tight pants (oh wait, that happens now too :P ). It's just a flag to determine if a document should show up on the front-end or not even if it is published, for example in a menu or other list when iterating over children.
I think you'll need to include the namespace:
as well, but again its strange because these should be automatically resolved based on the web.config.
Hi Shannon
Sorry I was being a bit slow! I use umbracoNaviHide all the time, I just didnt associate it with IsVisible! Doh!
One last thing, is it possible to use any of the strongly typed goodness in MacroScripts or am I limited to dynamic here??
Martin
MacroScripts will be deprecated in 6+ though we will support them for a while. The replacement is Partial View Macros which use the exact same syntax and object as MVC views. So in 6+, you will be able to use strongly typed goodness with Partial View Macros.
Shannon - thanks for the info, that explains why I knew about that namespace :) I had Views/web.config exclude in my VS solution. After including it, everything works automatically.
Martin - perhaps this is your problem too? I can confirm you shouldn't need to add that first namespace.
-Tom
the ~/Views/web.config should get created automatically if it is not there by our view engine. It is required for MVC to work properly. If it is not there, you'll probably end up with problems :)
is working on a reply...