Copied to clipboard

Flag this post as spam?

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


  • Lasse Kofoed 49 posts 177 karma points
    Nov 27, 2013 @ 15:31
    Lasse Kofoed
    0

    Umbraco 4.11.1 Contour 3.0.17 working, but needs XSLT render exsample

    I was forced to use XSLT to render a Contour form and found this project.I had to update some files, but it seams to work now.

    I have packed the edited project source to a ZIP.

    I have also edited the Example.xslt file, so that it autorenders fields in the form, the thing is that I dont want to write all of the fieldrendering types myself, and thougt that maybe someone have have done this already.

     

      <xsl:template match="/">
        <xsl:variable name="setFormGuid" select="rc:SetContourGuid('0d69c86c-e0b5-41df-9e03-19bcdfa07024')"/>
        <xsl:variable name="formGuid" select="rc:GetContourGuid()"/>
        <xsl:variable name="allFields" select="rc:GetFormFields()"/>
    
        <textarea>
          <xsl:copy-of select="$allFields"/>
        </textarea>
    
        <xsl:call-template name="RenderContourForm">
          <xsl:with-param name="form" select="$allFields"/>
        </xsl:call-template>
    
        <script type="text/javascript">
          <xsl:text>jQuery(document).ready(function () {</xsl:text>
          <xsl:value-of select="rc:BuildForm()"/>
          <xsl:text>});</xsl:text>
        </script>
    
      </xsl:template>
    <xsl:template name="RenderContourForm">
        <xsl:param name="form"/>
        <form action="" method="post" id="form-{$form/Id}" name="qaForm">
          <ul class="formArea">
            <xsl:for-each select="$form/Pages/Page/FieldSets/FieldSet/Fields/Field">
              <li>
                <label>
                  <xsl:attribute name="for">
                    <xsl:value-of select="./Caption"/>
                  </xsl:attribute>
                  <xsl:value-of select="./Caption"/>:
                </label>
                <xsl:choose>
                  <xsl:when test="./FieldTypeId = '3f92e01b-29e2-4a30-bf33-9df5580ed52c'">
                    <input type="text">
                      <xsl:attribute name="name">
                        <xsl:value-of select="./Caption"/>
                      </xsl:attribute>
                    </input>
                  </xsl:when>
                  <xsl:when test="./FieldTypeId = '023f09ac-1445-4bcb-b8fa-ab49f33bd046'">
                    <textarea class="textarea">
                      <xsl:attribute name="name">
                        <xsl:value-of select="./Caption"/>
                      </xsl:attribute>&nbsp;</textarea>
                  </xsl:when>
                  <xsl:when test="./FieldTypeId = 'd5c0c390-ae9a-11de-a69e-666455d89593'">
                    <input type="checkbox">
                      <xsl:attribute name="name">
                        <xsl:value-of select="./Caption"/>
                      </xsl:attribute>
                    </input>
                  </xsl:when>              
    
                </xsl:choose>
              </li> 
            </xsl:for-each>
    
          <li class="send-button">
            <input type="submit" value="Send" class="button" />
          </li>
          <li class="errorList">
            <ul class="errorList">
              <xsl:comment/>
            </ul>
          </li>
          </ul>
          <div class="formLoading hide">
            <h2>Processing</h2>
            <h4>The form is being sent</h4>
          </div>
          <div class="formPosted hide">
            <h2>Thanks</h2>
            <h4>We've successfully recieved the form, thanks!</h4>
          </div>
        </form>
      </xsl:template>
    
  • Comment author was deleted

    Nov 27, 2013 @ 15:33

    Did you see rest contour ? that includes a xslt render example http://our.umbraco.org/projects/website-utilities/cultiv-restcontour

  • Lasse Kofoed 49 posts 177 karma points
    Nov 27, 2013 @ 15:42
    Lasse Kofoed
    0

    Yes, that project is the one that i have modificed to make it work aginst 3.0 contour and not 1.1

    But the problem whit the samlefile is that it only has a hardcodede fields, or maybe im missing something here ? 

    The Samle file from RestContourPreview_0.8.0.zip

    <form action="" method="post" id="form-{$formGuid}" name="qaForm">

          <ul class="formArea">

            <li>

              <label for="Name">Name:</label>

              <input type="text" name="Name"/>

            </li>

            <li>

              <label for="Email">E-mail:</label>

              <input type="text" name="Email"/>

            </li>

     

     

  • Comment author was deleted

    Nov 27, 2013 @ 15:55

    Not familiar with the restcontour package so can't really help :(

  • Lasse Kofoed 49 posts 177 karma points
    Nov 29, 2013 @ 11:06
    Lasse Kofoed
    0

    Hello there, for anyone who can use it.

    This will rendering the following Contour type fields.

    Textbox Hiddenfield Password FileUpload Textarea Checkbox DropdownList CheckboxList RadioButtonList

    This will not render the following: Pageing, fieldsets, Recaptcha, DatePicker,

    Im thinking that i will move this into the Cultiv.RestContour.XsltExtensions at some point.

    <xsl:template name="RenderContourForm">
        <xsl:param name="form"/>
    
    
        <form action="" method="post" id="form-{$form/Id}" name="qaForm">
          <ul class="formArea">
            <xsl:for-each select="$form/Pages/Page/FieldSets/FieldSet/Fields/Field">
              <xsl:variable name="collectionName" select="./Caption"></xsl:variable>
              <li>
                <!--Label-->
                <label>
                  <xsl:attribute name="for">
                    <xsl:value-of select="$collectionName"/>
                  </xsl:attribute>
                  <xsl:value-of select="$collectionName"/>
                  <!--: <xsl:value-of select="./FieldTypeId"/>-->
                </label>
                <xsl:choose>
                  <!-- Textbox -->
                  <xsl:when test="./FieldTypeId = '3f92e01b-29e2-4a30-bf33-9df5580ed52c'">
                    <input type="text">
                      <xsl:attribute name="name">
                        <xsl:value-of select="./Caption"/>
                      </xsl:attribute>
                    </input>
                  </xsl:when>
                  <!--Hiddenfield-->
                  <xsl:when test="./FieldTypeId = 'da206cae-1c52-434e-b21a-4a7c198af877'">
                    <input type="hidden">
                      <xsl:attribute name="name">
                        <xsl:value-of select="./Caption"/>
                      </xsl:attribute>
                    </input>
                  </xsl:when>
                  <!--Password-->
                  <xsl:when test="./FieldTypeId = 'fb37bc60-d41e-11de-aeae-37c155d89593'">
                    <input type="password">
                      <xsl:attribute name="name">
                        <xsl:value-of select="./Caption"/>
                      </xsl:attribute>
                    </input>
                  </xsl:when>
                  <!--FileUpload-->
                  <xsl:when test="./FieldTypeId = '84a17cf8-b711-46a6-9840-0e4a072ad000'">
                    <input type="file">
                      <xsl:attribute name="name">
                        <xsl:value-of select="./Caption"/>
                      </xsl:attribute>
                    </input>
                  </xsl:when>
                  <!-- Textarea -->
                  <xsl:when test="./FieldTypeId = '023f09ac-1445-4bcb-b8fa-ab49f33bd046'">
                    <textarea class="textarea">
                      <xsl:attribute name="name">
                        <xsl:value-of select="./Caption"/>
                      </xsl:attribute>&nbsp;
                    </textarea>
                  </xsl:when>
                  <!-- Checkbox -->
                  <xsl:when test="./FieldTypeId = 'd5c0c390-ae9a-11de-a69e-666455d89593'">
                    <input type="checkbox">
                      <xsl:attribute name="name">
                        <xsl:value-of select="./Caption"/>
                      </xsl:attribute>
                    </input>
                  </xsl:when>
                  <!--DropdownList-->
                  <xsl:when test="./FieldTypeId = '0dd29d42-a6a5-11de-a2f2-222256d89593'">
                    <xsl:variable name="prevalues" select="rc:GetPrevaluesForField(./Id)"/>
    
                    <select>
                      <xsl:attribute name="name">
                        <xsl:value-of select="./Caption"/>
                      </xsl:attribute>
                      <xsl:for-each select="$prevalues/PreValue">
                        <option>
                          <xsl:value-of select="./Value"/>
                        </option>
    
                      </xsl:for-each>
                    </select>
                  </xsl:when>
                  <!--CheckboxList-->
                  <xsl:when test="./FieldTypeId = 'fab43f20-a6bf-11de-a28f-9b5755d89593'">
    
                    <xsl:variable name="prevalues" select="rc:GetPrevaluesForField(./Id)"/>
                    <xsl:for-each select="$prevalues/PreValue">
                      <input type="checkbox">
                        <xsl:attribute name="name">
                          <xsl:value-of select="$collectionName"/>
                        </xsl:attribute>
                        <xsl:attribute name="value">
                          <xsl:value-of select="./Value"/>
                        </xsl:attribute>
                      </input>
                      <xsl:value-of select="./Value"/>
                      <br/>
                    </xsl:for-each>
                  </xsl:when>
                  <!--RadioButtonList-->
                  <xsl:when test="./FieldTypeId = '903df9b0-a78c-11de-9fc1-db7a56d89593'">
                    <xsl:variable name="prevalues" select="rc:GetPrevaluesForField(./Id)"/>
                    <xsl:for-each select="$prevalues/PreValue">
                      <input type="radio">
                        <xsl:attribute name="name">
                          <xsl:value-of select="$collectionName"/>
                        </xsl:attribute>
                        <xsl:attribute name="value">
                          <xsl:value-of select="./Value"/>
                        </xsl:attribute>
                      </input>
                      <xsl:value-of select="./Value"/>
                      <br/>
                    </xsl:for-each>
                  </xsl:when>
                </xsl:choose>
              </li>
            </xsl:for-each>
    
            <li class="send-button">
              <input type="submit" value="Send" class="button" />
            </li>
            <li class="errorList">
              <ul class="errorList">
                <xsl:comment/>
              </ul>
            </li>
          </ul>
          <div class="formLoading hide">
            <h2>Afsender</h2>
            <h4>Din formular afsendes</h4>
          </div>
          <div class="formPosted hide">
            <h2>Tak</h2>
            <h4>
              <xsl:value-of select="$form/MessageOnSubmit"/>
            </h4>
          </div>
        </form>
      </xsl:template>
    
Please Sign in or register to post replies

Write your reply to:

Draft