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 16 posts 74 karma points
    Feb 04, 2015 @ 17:16
    David Podmore
    0

    How do I insert Contour form in a template macro?

    Hi,

    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.

  • Comment author was deleted

    Feb 04, 2015 @ 17:19

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

  • David Podmore 16 posts 74 karma points
    Feb 04, 2015 @ 18:14
    David Podmore
    0

    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>Name: @item.name</p>
              <p>Comment: @item.comment</p>
              <p>Email: @item.email</p>
              <p>Is this an answer? @item.isAnswer</p>
            }
          } else {
            <p>Look's like there are no comments... Add one below!</p>
          }
    
          <div>
            **TRYING TO INSERT THE FORM HERE**
          </div>
        }
      </umbraco:Macro>
    

    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:

Draft