Copied to clipboard

Flag this post as spam?

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


  • dominik 711 posts 733 karma points
    May 25, 2011 @ 12:02
    dominik
    0

    Use localLink and umbraco item recursive in c# (visual studio)

    Hello,

    Ive got the following code in my template:

    <p><a 
    href="{localLink:<umbraco:Item field='intLinkCreateAccount' 
    recursive='true' runat='server'></umbraco:Item>}" 
    class="register"><umbraco:Item field="#CreateAccount" 
    runat="server"></umbraco:Item></a> | <a href="#" 
    class="login-logout">Login</a></p>

    Now i want to use c# for doing this:

    lnkCreateAccount.Text = umbraco.library.GetDictionaryItem("CreateAccount"); gets the correct dictonary item but how can i use the {localLink} functionallity and the recursive="true" inside my Visual Studio procject?


  • dominik 711 posts 733 karma points
    May 25, 2011 @ 14:59
    dominik
    0

    ok i think i can use umbraco.library.NiceUrl instead of localLink but how can i get the umbraco item with recursive = True in umbraco

    lblCreateAccount.Text = umbraco.library.GetItem("intLinkCreateAccount");

    does not work. I need a possibility to get it with recursive="true"

    Can someone please help?

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    May 25, 2011 @ 15:12
    Jeroen Breuer
    0

    Are you using this C# code in a usercontrol? In that case instead of setting the text on a Label just place the Umbraco item in the .ascx file. That's supported :). So all the code you've got on your first post will work.

    Jeroen

  • dominik 711 posts 733 karma points
    May 25, 2011 @ 15:15
    dominik
    0

    i do not want to use the code in ascx file i want to use it inside the code behind script

    So please tell me how i can use the GetItem method with "recursive=true" inside the code behind script

     

    Thanks

  • Tom Fulton 2030 posts 4998 karma points c-trib
    May 25, 2011 @ 16:24
    Tom Fulton
    1

    Hi,

    If you use NodeFactory instead, you can create an extension method called GetPropertyValueRecursive to do this for you.

    At the bottom of this blog post is a useful UmbracoExtensions class that includes this and some other helpful functions.  It's written for the old version of nodeFactory but all you should have to do is change using umbraco.presentation.nodeFactory to umbraco.NodeFactory.

    Then you can do something like

    lblCreateAccount.Text = Node.GetCurrent().GetPropertyValueRecursive("intLinkCreateAccount");

    Hope this helps,
    Tom

Please Sign in or register to post replies

Write your reply to:

Draft