I am trying to loop through one folder and get the value from a property contained within the fields on a particular document type in a CSHTML file using Umbraco 6. So i used the default code and added a single line which throws an error:
@* Ensure that the Current Page has children, where the property umbracoNaviHide is not True *@
@if (Model.Children.Where("Visible").Any())
{
@* Get the first page in the children, where the property umbracoNaviHide is not True *@
var naviLevel = Model.Children.Where("Visible").First().Level;
@* Add in level for a CSS hook *@
<ul class="level-@naviLevel">
@* For each child page under the root node, where the property umbracoNaviHide is not True *@
@foreach (var childPage in Model.Children.Where("Visible"))
{
<li>
@{var img = Umbraco.TypedMedia(childPage.GetPropertyValue("imgName"));}
<a href="@childPage.Url">@childPage.Name + img</a>
@* if the current page has any children, where the property umbracoNaviHide is not True *@
@if (childPage.Children.Where("Visible").Any())
{
@* Call our helper to display the children *@
@childPages(childPage.Children )
}
</li>
}
</ul>
}
The error returned at first is The type or namespace name 'TypedMedia' does not exist in the namespace 'Umbraco' (are you missing an assembly reference?)
So i add @inherits umbraco.library at the top of the file and i get the error "no suitable method found to override". Could anyone advise how i am supposed to do this?
CSHTML looping through folder
I am trying to loop through one folder and get the value from a property contained within the fields on a particular document type in a CSHTML file using Umbraco 6. So i used the default code and added a single line which throws an error:
The error returned at first is The type or namespace name 'TypedMedia' does not exist in the namespace 'Umbraco' (are you missing an assembly reference?)
So i add
@inherits umbraco.library
at the top of the file and i get the error "no suitable method found to override". Could anyone advise how i am supposed to do this?Maybe this documentation can help: https://our.umbraco.org/documentation/Reference/Querying/UmbracoHelper/
Did it work out for you? Did you find a answer to your problem on the documentation page? Let me know if i can be of any help.
I found an example on the internet and used that instead
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.