Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Mr A 216 posts 278 karma points
    Sep 21, 2011 @ 12:08
    Mr A
    0

    Using Document type for Navigation

    Hi , A part of my tree is like :

    Categories

    sub-category1

    sub-category2

    sub-category2

    ContactUs

    Services

    What I am looking for is to show the sub categories menu on every node like contact us , services etc, I can acheive that by using simple razor syntax like :

    @inherits umbraco.MacroEngines.DynamicNodeContext

     @{

       foreach (var c in Model.NodeById(1001).Descendants().Where("umbracoNaviHide != true"))

    {<a href="@c.Url">@c.Name</a> } }

    Where 1001 is the node for category.
    What I want to show is the static display image which all the categories have which have a document type main image. I tried something like this with no success:
    @inherits umbraco.MacroEngines.DynamicNodeContext
      @{
       
        foreach (var c in Model.NodeById(1001).Descendants())
        {
     <div class="right-image1">  <a href="@c.Url"><img src="/ImageGen.ashx?image= @Model.GetProperty("serviceImage").Value&width=302&height=135&constrain=true"/></a> 
     
     </div>
        }
      
      }
    Following is the error which pops up using the above razor syntax:Error loading Razor Script service-submenu-images.cshtml
    Cannot perform runtime binding on a null reference

  • Dirk De Grave 4537 posts 6006 karma points MVP 3x admin c-trib
    Sep 21, 2011 @ 12:43
    Dirk De Grave
    0

    I guess you need to change @Model.GetProperty("serviceImage").Value into @c.GetProperty("serviceImage").Value

     

    Cheers,

    /Dirk

  • Mr A 216 posts 278 karma points
    Sep 21, 2011 @ 12:45
    Mr A
    0

    Cheers well i just sorted out and was about to reply ... nyway but u won :). So that means we can use document type properties on any templates??

  • 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.

Please Sign in or register to post replies