Portal Engine Questions on portal engine and web parts.
Version 6.x > Portal Engine > Document Attachments View modes: 
User avatar
Member
Member
ekeys-access - 7/16/2012 2:01:37 PM
   
Document Attachments
I am working in Kentico 6 and am having some issues trying to use the document attachments web part.

What I am trying to do is create a custom slide show out of images I have attached to the page (through the properties tab -> attachments tab). After attaching the images, I have added a document attachment web part. The path to the content is set to the current page and I am using a custom transformation (see below).

The I am using jQuery to create the slideshow which has thumbnail navigation. Instead of using separate images for the thumbnail navigation, I am resizing the original image in the transformation. In order for jQuery to pull the correct thumbnail for each image, I am storing the URL to the image attachments in a “data-“ property. The main images are being displayed, however, the thumbnail image is not being found (even though it’s the same as the original image, just resized with “?maxsidesize”). Is there something else that I can use in my transformation to get the actual physical path to use in the data- property for the thumbnail image? Right now, the url is showing as http://localhost:54075/KenticoCMS/getattachment/Events/image.jpg which jQuery is returning as undefined.

Here is the transformation I am using created under cms.Root:

<li><img style="border: none;" src="<%# IfCompare(ImageHelper.IsImage((string)Eval("AttachmentExtension")), true, GetAttachmentIconUrl(Eval("AttachmentExtension"), null), GetAbsoluteUrl(GetAttachmentUrl(Eval("AttachmentName"), Eval("NodeAliasPath")), Eval<int>("AttachmentSiteID"))) %>" data-thumb="<%# IfCompare(ImageHelper.IsImage((string)Eval("AttachmentExtension")), true, GetAttachmentIconUrl(Eval("AttachmentExtension"), null), GetAbsoluteUrl(GetAttachmentUrl(Eval("AttachmentName"), Eval("NodeAliasPath")), Eval<int>("AttachmentSiteID"))) %>" alt="<%# GetNotEmpty("AttachmentTitle;AttachmentName") %>" /></li>


Thanks for the help

User avatar
Kentico Developer
Kentico Developer
kentico_helenag - 7/23/2012 3:52:34 AM
   
RE:Document Attachments
Hello,


It is strange, the URL should be correct. I suppose that you display an attachment: image.jpg on the /Events document, right?

If you use the same URL in a new window (or in a different browser), does it display the image correctly?

This URL is not a physical path to the image, the URL needs to be re-written by Kentico to get the correct image. Does jQuery need a physical location of the thumbnail?


Best regards,
Helena Grulichova


User avatar
Member
Member
ekeys-access - 7/23/2012 8:43:16 AM
   
RE:Document Attachments
Yes, it does display correctly in a new window when I copy and paste the URL. I think jQuery needs the physical path to the file. Is this possible to do?

User avatar
Certified Developer 8
Certified Developer 8
Jiveabillion - 7/23/2012 8:58:52 AM
   
RE:Document Attachments
If you can access it in the browser, then jQuery can access it. It can even have the .aspx extension and work just fine. I would look for another reason that it isn't working.

User avatar
Kentico Developer
Kentico Developer
kentico_helenag - 7/23/2012 9:21:33 AM
   
RE:Document Attachments
Hello,


it is possible the URL to the physical file by API:

CMS.TreeEngine.AttachmentManager.GetFilePhysicalURL(String siteName, String fileGuid, String fileExtension)

You can create a custom transformation function for this: Adding custom functions to transformations. The parameters for the mentioned function are accessible by the Eval function.

You can find the physical files in your project folder by default in ~/<site code name>/files/<two letters from fileGuid>/fileGuid.<extension>.


Best regards,
Helena Grulichova