Portal Engine Questions on portal engine and web parts.
Version 4.x > Portal Engine > Getting object View modes: 
User avatar
Member
Member
rybin-proforce - 2/11/2009 9:30:30 AM
   
Getting object
Hello!

I make new webpart. It contain image, which is defined by administrator while placing webpart instance on a page.
I made a new property of type "Image selection".
And get the value in webpart code
object Obj = PartInstance.GetValue("DownImage");

However, Obj is string that contain some guid value (I think it is image identifier).
How I can get image url?

Thank you

User avatar
Member
Member
Elijah - 2/15/2009 10:16:02 AM
   
RE:Getting object
Kentico doesn't store files in the web part or document type tables. It stores them in the CMS_Attachment table. You are correct, it's a foreign key GUID you're seeing.

One way to display the image is using the getattachment script. Here's a snippet from the documentation:

------

Linking attachments

If you need to create a permanent link to a file uploaded to some document, such as DOC, PDF or image uploaded in the product form, you need to use a URL in the following format:

http://www.mydomain.com/getattachment/763c8921-be94-4610-99b4-25e8d3be5b08/logo.aspx

The URL consists of the following parts:

<domain>/getattachment/<file GUID>/<filename><extension>

The <file GUID> value is not the same as document GUID. It's a GUID of the file in the CMS_Attachment table. You can find this GUID if you display the image in the CMS Desk and see its URL.

The <file name> value can contain any text.

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 2/17/2009 1:12:54 AM
   
RE:Getting object
Hello,

The above post from Elijah is also correct and explains it very good.

I just want to add here that if you want to have a user friendly URL, you can take a look here - http://devnet.kentico.com/Knowledge-Base/API-and-Internals/How-to-display-link-to-a-file-or-document-without-.aspx.

It is mainly for document selector and for transformations, but the code is very similar and you can take inspiration from it. I hope it will help.

Best Regards,
Juraj Ondrus