Copied to clipboard

Flag this post as spam?

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


  • Anthony Candaele 1197 posts 2049 karma points
    Apr 10, 2012 @ 17:41
    Anthony Candaele
    0

    how to get a doctype property value in a template

    Hi,

    For my EditJob job template I want to access the title of a job document type property jobFunctionTitle. I would like to use a inline razor script in my template.

    On the wiki I read there is a method to access a node by id where the id is passed by a querystring:

    new DynamicNode(HttpContext.Current.Request.QueryString["id"])

    Now my question is, how can I access the jobFunctionTitle property in my inline razor script, a use it in my template, something like:

    <h2>Edit Job: [dynamic value for jobFunctionTitle]

    I guess this must be plain simple, but I'm pretty inexperienced by using Razor in Umbraco Templates

    Thanks for your help,

    Anthony

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Apr 10, 2012 @ 20:15
    Tom Fulton
    1

    Hi Anthony,

    There is a function Library.NodeById that you can use to get a node from it's ID.  This should do the trick:

      <umbraco:Macro runat="server" language="cshtml">
        @{
        var jobNodeId = HttpContext.Current.Request.QueryString["id"];
        var jobNode = Library.NodeById(jobNodeId);
        <h2>Edit Job: @jobNode.Name</h2>
        }
      </umbraco:Macro>

    HTH,
    Tom

  • Anthony Candaele 1197 posts 2049 karma points
    Apr 10, 2012 @ 21:06
    Anthony Candaele
    0

    Hi Tom,

    Thanks a lot man, this works perfectly!

    greetings,

    Anthony

    ps: still working on this human resources site, but it's pretty big, lot's of interactive features for employers and jobseekers. It will be my biggest Umbraco website, feature wise.

Please Sign in or register to post replies

Write your reply to:

Draft