Thanks for such a quick reply. It is much appreciated! So all the helper methods explained in the link in my post and related links don't work yet?
I thought they have been standard umbraco helper methods.
If you don't mind, could you please help me translate my partial view below into something that works in v5.
It should create a description meta tag using a "metaDescription" property (simple text string), and if that property doesn't exist or is empty use the "mainContent" property (rich text editor), strip out any html tags (img, a tags etc) and truncate the result to 200 characters.
From the link documentation for V4.7.1 the below should work I think but it doesn't. I get errors around @Library not existing and Truncate not liking the IHtmlString parameter, even though one of the overloads says that it should be fine.
Thanks again!
Dean
@inherits RenderViewPage
@using System.Web.Mvc.Html
@using Umbraco.Cms.Web
@{
var content = Umbraco.Field("metaDescription", removeParagraphTags: true); if (content == DynamicNull) Umbraco.Truncate(Library.StripHTML(DynamicModel.mainContent), 200, "...");
What using statement required to utilise @Library in Umbraco 5
Hello all.
Please please please help!!!
I'm just looking to use @Library.StripHTML in a partial view but keep getting the error that @Library doesn't exist.
I've tried all the combinations of usings/inherits and @DynamicModel.StripHTML, @Model.StripHTML @Library.StripHTML
What are the standard using and inherrits statements that should be at the top of layout templates and partial views for Umbraco V5?
The only documentation I can find to help me through this first attempt using V5 is here
http://umbraco.com/follow-us/blog-archive/2011/9/22/umbraco-razor-feature-walkthrough%E2%80%93part-8.aspx
but alot of it doesn't seem to work with V5
Please help, i'm finding it very difficult and frustrating changing over from V4 with the lack of up to date documentation.
I suppose it doesn't help that it is my first attempt using MVC either!
Thanks in advance
Dean
Hi Dean
I don't think that @library has been implemented in v5 yet.
But maybe you can use the @Html.Raw() nugget insted? Like this...
@Html.Raw(DymamicModel.bodyText)
Hope this helps.
/Jan
Wow, Jan.
Thanks for such a quick reply. It is much appreciated! So all the helper methods explained in the link in my post and related links don't work yet?
I thought they have been standard umbraco helper methods.
If you don't mind, could you please help me translate my partial view below into something that works in v5.
It should create a description meta tag using a "metaDescription" property (simple text string), and if that property doesn't exist or is empty use the "mainContent" property (rich text editor), strip out any html tags (img, a tags etc) and truncate the result to 200 characters.
From the link documentation for V4.7.1 the below should work I think but it doesn't. I get errors around @Library not existing and Truncate not liking the IHtmlString parameter, even though one of the overloads says that it should be fine.
Thanks again!
Dean
@inherits RenderViewPage
@using System.Web.Mvc.Html
@using Umbraco.Cms.Web
@{
var content = Umbraco.Field("metaDescription", removeParagraphTags: true);
if (content == DynamicNull)
Umbraco.Truncate(Library.StripHTML(DynamicModel.mainContent), 200, "...");
}
<meta name="Description" content="@content" />
Hi Dean
Sorry for my late second reply. Have been a bit busy the last couple of days.
But yes the stuff you have read about in the above link is only valid for Razor in 4.7.1 - Not in Umbraco 5.
I think you should be able to do something like
var content = Umbraco.Field("bodyText", altFieldAlias: "mainContent", removeParagraphTags: true,))
Must admit I'm not sure how to limit the alternative field to only take the first 200 characters though...
/Jan
Hi Jan,
Thanks for your reply,
Yep, I'll have to work with that and maybe remove the html and trim the text after the fact.
Hopefully it won't be too long before the library stuff is added to V5.
Cheers
Dean
Hi Dean!
There is nothing wrong in @Library.StripHTML except Lettter casing....just use @Library.StripHtml instead....it will work
You dont have to include any additional reference for this too.... just use @inherits umbraco.MacroEngines.DynamicNodeContext......its enough for it.
ZiaBukhari
is working on a reply...