Copied to clipboard

Flag this post as spam?

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

  • David Podmore 15 posts 73 karma points
    Feb 04, 2015 @ 17:16
    David Podmore

    How do I insert Contour form in a template macro?


    I'm fairly new to cshtml/razor, and struggling to insert a contour form via a macro in a template. I've tried using both a "Rich Text" and "Form Picker" datatype on the doctype, but can't get the form to render correctly.

    I've read through this thread, but it appears that it refers mostly to Umbraco v6+, the trouble is we're still using v4.7.0

    I'm sure there must be an easy way to do this, so any help would be appreciated!

    Thanks, David.

  • Tim Geyssens 6499 posts 15238 karma points MVP 2x c-trib
    Feb 04, 2015 @ 17:19
    Tim Geyssens

    How does it render, does it render something or ... ?

  • David Podmore 15 posts 73 karma points
    Feb 04, 2015 @ 18:14
    David Podmore

    Here's the macro as it stands (still a work in progress):

    <umbraco:Macro runat="server" language="cshtml">
        @inherits umbraco.MacroEngines.DynamicNodeContext
        @if(Model.Children.Where("NodeTypeAlias == \"CampaignQAForm\"").Count() > 0) {
          if(Model.Children.Where("NodeTypeAlias == \"CampaignQA\"").Count() > 0) {
            foreach(var item in Model.Children.Where("NodeTypeAlias == \"CampaignQA\"")){
              <p>Comment: @item.comment</p>
              <p>Is this an answer? @item.isAnswer</p>
          } else {
            <p>Look's like there are no comments... Add one below!</p>

    When "CampaignQAForm" has "form" as a Rich Text data type, I've used:

    @Model.Children.Where("NodeTypeAlias == \"CampaignQAForm\"").First().form

    This gives the following error:

    Error loading Razor Script 'umbraco.MacroEngines.DynamicNodeList' does not contain a definition for 'First'

    When "CampaignQAForm" has "form" as a Form Picker, I've used:

    @Umbraco.RenderMacro("umbracoContour.RazorRenderForm", new{ FormGuid = "08885c84-5dab-4562-a46d-8a89cef3e115" })

    Which gives the following error:

    Error loading Razor Script d:\inetpub\wwwroot\Flowcrete\App_Data\TEMP\Razor\inline-53180e55e27180395360b90e28f30c22.cshtml(17): error CS0234: The type or namespace name 'RenderMacro' does not exist in the namespace 'Umbraco' (are you missing an assembly reference?)

    I hope this makes sense?

    Thanks, David.

Please Sign in or register to post replies

Write your reply to: