Copied to clipboard

Flag this post as spam?

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


  • Max Mumford 266 posts 293 karma points
    Jul 07, 2011 @ 18:56
    Max Mumford
    0

    Render macro from xslt - cannot parse error

    Hi all,

    I need to get an xslt macro to render a usercontrol macro depending on the value of a node property. I am getting a "cannot parse xslt" error:

     

      <xsl:choose>
        <xsl:when test="$currentPage/uBlogsyPostDisableComments != 1">
          <form runat="server">
            <xsl:value-of select="umbraco.library:RenderMacroContent('&lt;?UMBRACO_MACRO macroAlias=&quot;Doc2FormComplete&quot; Alias=&quot;Doc2FormComplete&quot; DocumentType=&quot;10673&quot; Template=&quot;&quot; TabName=&quot;comment&quot; PageTabs=&quot;0&quot; HideTabNames=&quot;1&quot; ChooseWhereToStore=&quot;[#pageID]&quot; EditMode=&quot;0&quot; ShowTitle=&quot;0&quot; TitleName=&quot;&quot; SaveMemberAlias=&quot;, &quot; ShowDescriptions=&quot;0&quot; SubmitButtonText=&quot;Post&quot; PreviousButtonText=&quot;&quot; NextButtonText=&quot;&quot; RequiredText=&quot;&quot; PublishOnSubmit=&quot;0&quot; RefreshToParent=&quot;0&quot; RedirectToNode=&quot;&quot; PublishWithUserId=&quot;&quot; StorePropertiesInCookies=&quot;&quot; SendEmailResponse=&quot;0&quot; ResponseSubject=&quot;&quot; ResponseEmailFieldAlias=&quot;, &quot; ResponseCopyTo=&quot;&quot; EmailForm=&quot;0&quot; FormSubject=&quot;&quot; FormToEmailAddress=&quot;&quot; FormFromEmailAddress=&quot;&quot; UseAjax=&quot;1&quot; DefaultValueNode=&quot;&quot; TextOnSubmit=&quot;Thanks for your comment. It will be moderated then published.&quot; runat=&quot;server&quot; runat=&quot;server&quot;&gt;&lt;/?UMBRACO_MACRO&gt;', @id)" disable-output-escaping="yes"/>
          </form>
        </xsl:when>
        <xsl:otherwise>
          <br /><div class="info">Comments have been <strong>closed</strongfor this post.</div>
        </xsl:otherwise>
      </xsl:choose>

    I wrote the macro tag according to this document:

    http://en.wikibooks.org/wiki/Umbraco/Reference/umbraco.library/RenderMacroContent

    Notice the "Version 4 warning" paragraph.

    I am using Umbraco version 4.7. 

    Can anybody see what is going wrong?

    Thanks,
    Max.

     

  • Tom Fulton 2030 posts 4996 karma points c-trib
    Jul 07, 2011 @ 19:46
    Tom Fulton
    0

    Hi,

    Is this being run inside a for-each loop or match template?  I ask because you specify the pageid as "@id" - which I think would only work inside a for-each or match template.  Have you tried changing to $currentPage/@id?

    -Tom

  • Dirk De Grave 4537 posts 6006 karma points MVP 3x admin c-trib
    Jul 07, 2011 @ 22:32
    Dirk De Grave
    1

    Max,

    You can't use RenderMacroContent() for a macro referencing a user control. So, even if you get the syntax right, it simply won't work.

     

    Cheers,

    /Dirk

  • Max Mumford 266 posts 293 karma points
    Jul 08, 2011 @ 10:44
    Max Mumford
    0

    Oh I see. My problem is, I want to render the doc2form macro only if a document property does not equal 1. I cannot easily edit the user control to do it inside the .net code. How should I go about achieving this?

    Thanks.

    Max.

  • Dirk De Grave 4537 posts 6006 karma points MVP 3x admin c-trib
    Jul 08, 2011 @ 10:48
    Dirk De Grave
    0

    Max,

    Need some c# code for that as in

    var node = new Node(id);
    // or var node = Node.GetCurrent();
    var propertyValue = node.getProperty("propertyAlias").Value;

    (may need a cast to boolean as .Value() returns a string. Don't forget to include the necessary assemblies such as umbraco, cms, businesslogic)

     

    Cheers,

    /Dirk

  • Max Mumford 266 posts 293 karma points
    Jul 08, 2011 @ 10:50
    Max Mumford
    0

    So there is no way to do this without editing the user control's source? I was hoping there would be a simple way with xslt or built in umbraco functionality..

    I think if I do have to edit the source directly I might just create a second template without the comment form and allow the user to switch between the two..

    Thanks

  • Stuart Burrows 61 posts 110 karma points
    Jul 08, 2011 @ 11:26
    Stuart Burrows
    1

    Do you need to do this in an xslt? Might be better in the template itself - so you could have:

     

    <% 
        string commentStatus = umbraco.presentation.nodeFactory.Node.GetCurrent().GetProperty("uBlogsyPostDisableComments").Value;
        if (commentStatus != "1") { %>
            <form runat="server">
                <umbraco:Macro macroAlias="Doc2FormComplete" Alias="Doc2FormComplete" /> <!-- you need to add you other parameters naturally -->
            </form> 
        <% } else { %>
            <br /><div class="info">Comments have been <strong>closed</strong> for this post.</div>
    <% } %>

     

  • Max Mumford 266 posts 293 karma points
    Jul 08, 2011 @ 11:48
    Max Mumford
    0

    Perfect! I hadn't thought of inline .net as I'v never used it before. Thanks for the help everybody.

  • 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