ASPX templates
Version 3.x > ASPX templates > Linked document with images View modes: 
User avatar
Member
Member
edurocher@enzy.com - 3/19/2009 11:16:07 PM
   
Linked document with images
I have images (i.e. files) that are a property of a custom document. When I use a cms repeater on that site to list the documents and use the “<%# GetImage("Picture") %>” tag in my transform, all is good.

I need to use these same documents on a separate site. I created links to each of the documents and setup a new page with a repeater listing the linked documents (I do not want the repeater to look at the other site because that causes links to use the pathing on the other site). I see the data fine but it is not displaying the image (using the same transform as the other site with the GetImage tag). I do not get an error, there is simply nothing displayed.

I am using v3.1a. Am I using the correct technique to accomplish this? From what I can tell, the link that is being built to display the image is not happy with the image belonging to a different site. Are there parameters I can add to tell it that the image is on the original documents site?

Thanks in advance.

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 3/24/2009 9:18:20 AM
   
RE:Linked document with images
Hi,

In this case the image is not resolved because in the URL is used the current site domain name.
You can use in the transformation something like this:

<img src="http://site_1_domain<%# GetFileUrl("<image_field_name>") %>" />

Or, you can add a custom function for transformations if you want to use it more often - www.kentico.com/docs/devguide/adding_custom_functions_to_tra.htm.

Best Regards,
Juraj Ondrus

User avatar
Member
Member
tmartin-wernervas - 4/16/2012 12:39:47 PM
   
RE:Linked document with images
I have a very similiar scenario where we have multiple sites that we want to be able to share news items across. I do not want to hard code the site domain into the transformation or into a custom function. I was wondering if in the transformation or in the custom function can I get the correct site domain information for the url using the NodeLinkedNodeSiteID if it is set?

Thanks
Troy Martin

User avatar
Kentico Support
Kentico Support
kentico_zdenekc - 4/18/2012 2:25:46 AM
   
RE:Linked document with images
Hi,

If you're getting not just the current site (from the context) but any site, the custom function would be the most reliable way. Inside this function, you can use

SiteInfoProvider.GetSiteInfo(NodeLinkedNodeSiteID)

to get the SiteInfo object, which has the property

DomainName

that you can easily use to build your link.
Optionally you may pick one of the "SiteDomainAliases" hashtable.

Should you need any additional details, please feel free to ask.

Regards,
Zdenek