Portal Engine Questions on portal engine and web parts.
Version 7.x > Portal Engine > productlist transformation View modes: 
User avatar
Member
Member
peterm-technologyevaluation - 2/12/2013 5:21:27 PM
   
productlist transformation
I have a document type defined with excel attachment and e-commerce product attached. The document type has a field called "sample" and it is document attachment.

I want to show list of documents/products with short descriptions and sample links (excel icons which user can click and see an attached excel sample)

I have repeater which uses CorporateSite.Transformations.ProductList transformation which I am trying to modify in order show excel icon so when a user click it show preview sample.

What I did I took the code from document attachment transformation and put inside productlist list transformation.
<%@ Register Src="~/CMSModules/Ecommerce/Controls/ProductOptions/ShoppingCartItemSelector.ascx" TagName="CartItemSelector" TagPrefix="uc1" %>
<%@ Register Src="~/CMSInlineControls/DocumentAttachments.ascx" TagName="DocumentAttachments" TagPrefix="cms" %>
<div class="ProductPreview">
<div class="ProductBox">
##editbuttons##

<!-- document attachment code -->
<%#Eval("sample")%>
<div>
<img src="<%# GetAttachmentIconUrl(Eval("AttachmentExtension"), "List") %>" alt="<%# Eval("AttachmentName",true) %>" />
 
<a target="_blank" href="<%# GetAbsoluteUrl(GetAttachmentUrl(Eval("AttachmentName"), Eval("NodeAliasPath")), EvalInteger("AttachmentSiteID")) %>">
<%# Eval("AttachmentName",true) %>
</a>
</div>
<!-- document attachment code -->

<a href="<%# GetDocumentUrl() %>">
<span class="ProductTitle textContent">
<%# HTMLEncode(ResHelper.LocalizeString(Convert.ToString(Eval("SKUName")))) %>
</span>
</a>   <strong><%# GetSKUFormattedPrice(true, false) %></strong>
<br>
<span style="font: bold 14px arial, geneva; color: #008000;"><%# Eval("criteria")%> Criteria</span> <br />
<%# Eval("SKUShortdescription")%>
<div class="ProductFooter">

<uc1:CartItemSelector id="cartItemSelector" runat="server" SKUID='<%# ValidationHelper.GetInteger(Eval("SKUID"), 0) %>
' SKUEnabled='
<%# ValidationHelper.GetBoolean(Eval("SKUEnabled"), false) %> ' AddToCartImageButton="~/App_Themes/CorporateSite/Images/btn_addToShoppingCart.png" />
</div>
</div>
</div>
<br style="clear: both;">

Any ideas why?

User avatar
Member
Member
peterm-technologyevaluation - 2/13/2013 12:45:46 PM
   
RE:productlist transformation
I guess I didnt make myself clear enough. I am using repeater with CorporateSite.Transformations.ProductList transformation. I want to show attachment for each product.

I took a code from CMS.Root.AttachmentList transformation and put inside productlsit transformation. It doesn't work, although it document attachment web part works fine (this web part uses CMS.Root.AttachmentList transformation).

Thanks

User avatar
Kentico Support
Kentico Support
kentico_zdenekc - 2/20/2013 7:52:14 PM
   
RE:productlist transformation
Hi,

You're using the transformation code (marked with <!-- document attachment code --> ) that is meant for the DocumentAttachments control (linked in the 2nd row of the transformation), that will not work here.

In the transformation you posted, you are in the context of your custom document type, where the only available field related to attachments is the "sample" field (holding most probably the attachment GUID if a single attachment is used - i.e. not grouped attachments).

You cannot evaluate the attachment-specific fields like Eval("AttachmentExtension") directly in your transformation - this field is just not available in this context.

You will either need to insert the DocumentAttachments control into the transformation and set it's transformation to the default (CMS.Root.AttachmentList) or other transformation which operates over the Attachment objects, not over your documents. You can see this case nicely explained in the Handling attachments in transformations DevGuide article.

Or, you could use the methods for transformations to obtain the link (and icon) to the attachment directly from the single attachment field:
GetFileIconUrl(object attachmentGuidColumn)
example:
<%# GetFileIconUrl("sample") %>
Returns URL of the file type icon according to the extension of the file stored in the specified column.

GetFileUrl(object attachmentGuidColumn)
example:
<%# GetFileUrl("sample") %>
Returns URL of the file specified by the attachment GUID column of the given name.

You can find the methods described in the Transformation editor context help, available typically at ~/CMSHelp/index.html?newedit_transformation_methods.htm

Hope this will help.

Regards,
Zdenek