+1-888-365-2779
Try Now
More in this section

Forums / Ecommerce / Format of custom product propertys, ProductDynamicFields

Format of custom product propertys, ProductDynamicFields

8 posts, 1 answered
  1. Corby
    Corby avatar
    48 posts
    Registered:
    19 Sep 2011
    29 Mar 2012
    Link to this post
    So I have a custom product type and associated with that are custom product fields that Sitefinity let me add via the admin tool.  Now I want to display my products on a page and in viewing the template, I found this.

    <%--NOTE: Uncomment the next line to display custom product fields-%>
    <sf:ProductDynamicFields id="productDynamicFields" runat="server"
    </sf:ProductDynamicFields>

    I can uncomment as suggested and my fields do show up, but they are not in the order I want and they are not formatted how I want them.  This is how they are:
    FieldNameA:
    Value
    FieldNameB:
    Value 
    FieldNameC:
    Value 

    I'd like to be able to format them like:
    FieldNameC: Value , FieldNameA: Value ,  FieldNameB: Value

    It seems as though I don't have any level of control over custom "Dynamic Product Fields".  Am I missing something?  Anyone have any suggestions?

  2. Jochem Bökkers
    Jochem Bökkers avatar
    787 posts
    Registered:
    13 Aug 2007
    29 Mar 2012
    Link to this post
    Hey Corby,
    Are you using the default template with the default styling classes?

    Jochem
  3. Corby
    Corby avatar
    48 posts
    Registered:
    19 Sep 2011
    29 Mar 2012
    Link to this post
    Yes, the default template had the piece where I can uncomment out and it will show the dynamic fields.  But they're not formatted like I want.  I've been looking for documentation on how to display those custom fields but just haven't hit it yet so I thought I'd post on the forum in case the answer is "it's not possible".
  4. Jochem Bökkers
    Jochem Bökkers avatar
    787 posts
    Registered:
    13 Aug 2007
    29 Mar 2012
    Link to this post
    Hey Corby,

    ProductDynamicFields are currently in a ul/li by ways of a repeater displayed as followed:

    <asp:Repeater ID="dynamicFieldsRepeater" runat="server">
      <HeaderTemplate>
        <ul class="sfproductDynamicFieldsList">
      </HeaderTemplate>
      <ItemTemplate>
        <li class="sfproductDynamicField">               
        <sf:SitefinityLabel id="fieldTitle" runat="server" WrapperTagName="strong" CssClass="">
        </sf:SitefinityLabel>:
        <sf:SitefinityLabel id="fieldValue" runat="server" WrapperTagName="div" CssClass="sfproductField">
        </sf:SitefinityLabel>
         </li>
      </ItemTemplate>
      <FooterTemplate>
        </ul>
     </FooterTemplate>
    </asp:Repeater>

    I'm pretty sure you can override this template if you're not happy with trying a css approach to float:left the ul/li, but can't test (and give an example on how to override the template) till later tonight...

    Let me know if this is sufficient or you'd like me to see what can be done about completely overriding the template.

    Jochem
  5. Corby
    Corby avatar
    48 posts
    Registered:
    19 Sep 2011
    29 Mar 2012
    Link to this post
    I'm pulled away on another project and probably won't be able to get to this today.  Thank you for the info.  I will attempt what you've got here and see if it does the trick.  If not, I'll repost to this thread my findings and we can pick up from there if you'd like.  Thank you very much.
  6. Corby
    Corby avatar
    48 posts
    Registered:
    19 Sep 2011
    30 Mar 2012
    Link to this post
    I dropped your code suggestion above under the H2 tag from the default template that lists the title of the product.  The result was "Error parsing the template".  So perhaps just dropping it there was not the right approach.  Can you suggest where inside the default template to place your suggested code?

    Is there a way within Sitefinity when editing the default template to enable on the right side under "Insert" and "Other Data" to allow for the custom fields to be populated there?
  7. Jochem Bökkers
    Jochem Bökkers avatar
    787 posts
    Registered:
    13 Aug 2007
    02 Apr 2012
    Link to this post
    Hey Corby,

    I'm sorry for the belated response. The code snippet was just to show you what Sitefinity will output by default (so you'd see the structure and markup classes) not to be dropped inside the widget.

    If you want you can manually add the code for the custom fields as followed:

    <sitefinity:TextField
     ID="TextFieldCustomField"
     runat="server"
     DisplayMode="Read"
     Value='<%# Eval("CustomFieldName")%>'
     CssClass="CustomFieldClass"
    />

    And replace 'CustomField' to whatever you named it.
    Jochem.
    Answered
  8. Corby
    Corby avatar
    48 posts
    Registered:
    19 Sep 2011
    02 Apr 2012
    Link to this post
    That's exactly what I was looking for.  Thank you.  

    Also for others, when adding this code snippet with your custom field names, you have to update the ID value so it is unique (if you are showing more than one custom field.)

    <sitefinity:TextField
     ID="TextFieldCustomField_unique1"
     runat="server"
     DisplayMode="Read"
     Value='<%# Eval("CustomFieldName1")%>'
     CssClass="CustomFieldClass"
    />

    <sitefinity:TextField
     ID="TextFieldCustomField_unique2"
     runat="server"
     DisplayMode="Read"
     Value='<%# Eval("CustomFieldName2")%>'
     CssClass="CustomFieldClass"
    />

8 posts, 1 answered