Copied to clipboard

Flag this post as spam?

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


  • Tom W 39 posts 96 karma points
    Jul 27, 2011 @ 11:37
    Tom W
    0

    Canvas and Razor

    Hi,

    Been loving the Razor view engine in 4.7, but I was wondering - is there any way to allow "canvas" editing?

    I have a particular need for inline editing on a client's site, and would love to use Razor, but at the moment I'm having to use XSLT

    <xsl:value-of select="umbraco.library:Item(@id, 'content')" />

    In a template or user control, I can use

    <umbraco:Item field="content" runat="server" />

    Can anyone point me in the right direction for something similar with Razor?

    Thanks

    Tom

  • Sebastiaan Janssen 5058 posts 15520 karma points MVP admin hq
    Jul 27, 2011 @ 11:40
    Sebastiaan Janssen
    0

    I have never used Canvas editing, so I'm not sure how it works. but if that XSLT works, why not try:

    @umbraco.library.Item(Model.Id, "content")
  • Tom W 39 posts 96 karma points
    Jul 27, 2011 @ 11:52
    Tom W
    0

    Thanks Sebastian, I will.

    Strangely, .Item() does not come up in intellisense in VS2010 (all other methods do), but it must be there! Protected perhaps, or an extension method. Doesn't error on compilation. 

    I'll post back and resolve once I've confirmed if this works.

  • Sebastiaan Janssen 5058 posts 15520 karma points MVP admin hq
    Jul 27, 2011 @ 12:09
    Sebastiaan Janssen
    0

    Hmm, looks like it's an alias for GetItem() instead. :-)

  • Tom W 39 posts 96 karma points
    Jul 27, 2011 @ 12:09
    Tom W
    0

    Hmm, it's not a static method

    An object reference is required for the non-static field, method, or property 'umbraco.library.Item(int, string)'

    And the following:

    @{
        var library = new umbraco.library();
    }
    @library.Item(Model.Id, "content"

    Renders:

     [ [ [ [umbraco:Item nodeId="1512" field="content" ] ] ] ]

    and

    @umbraco.library.GetItem(Model.Id, "content")
    

    renders nothing.

    So, it looks like the page lifecycle is coming into play here. Not sure it's an option, unless anyone has any other ideas?

    Thanks in advance,

    Tom

     

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

    If the problem is the page lifecycle you should read this topic: http://our.umbraco.org/forum/developers/razor/21722-Set-Razor-macro-parameters-in-code-behind. It might help.

    Jeroen

Please Sign in or register to post replies

Write your reply to:

Draft