Copied to clipboard

Flag this post as spam?

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


  • Kaj 41 posts 73 karma points
    Sep 25, 2011 @ 07:58
    Kaj
    0

    Get url and node name from content picker?

    I have one dokument type with 5 content picker. I whant do a razor script who give me links to this 5 ithem that been picked, and the linkname should be same as the node-name on the node who was pecked.

    Can any one show how I can do that?

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Sep 25, 2011 @ 14:54
    Sebastiaan Janssen
    1

    Assuming that your pickers are called: contentPicker1, contentPicker2, contentPicker3, contentPicker4 and contentPicker5:

    @{ var picker1 = @Model.NodeById(Model.contentPicker1); }
    <a href="@picker1.Url">@picker1.Name</a>

    @{ var picker2 = @Model.NodeById(Model.contentPicker2); }
    <a href="@picker2.Url">@picker2.Name</a> 

    And the same for 3-5.

     

  • James Smyth 4 posts 24 karma points
    May 23, 2012 @ 18:31
    James Smyth
    0

    Sebastiaan, why doesn't this block work? Its throwing up a 'Compliation Error'

     

    Is there anything obviously wrong with my 'foreach' here?

      @foreach(var page in @Model.Children()){
      <li>
              <a href="@page.Url">@page.Name</a>      
      </li>
      }
  • Douglas Ludlow 210 posts 366 karma points
    May 24, 2012 @ 15:24
    Douglas Ludlow
    0

    Probably because Children is not a method, it's a property. So you would do:

    @foreach(var page in Model.Children)
    {
    <li><a href="@page.Url">@page.Name</a></li>

     

     

Please Sign in or register to post replies

Write your reply to:

Draft