Format of custom product propertys, ProductDynamicFields

Posted by Community Admin on 05-Aug-2018 15:32

Format of custom product propertys, ProductDynamicFields

All Replies

Posted by Community Admin on 29-Mar-2012 00:00

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?

Posted by Community Admin on 29-Mar-2012 00:00

Hey Corby,
Are you using the default template with the default styling classes?

Jochem

Posted by Community Admin on 29-Mar-2012 00:00

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".

Posted by Community Admin on 29-Mar-2012 00:00

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

Posted by Community Admin on 29-Mar-2012 00:00

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.

Posted by Community Admin on 30-Mar-2012 00:00

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?

Posted by Community Admin on 02-Apr-2012 00:00

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.

Posted by Community Admin on 02-Apr-2012 00:00

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"
/>

This thread is closed