Portal Engine Questions on portal engine and web parts.
Version 6.x > Portal Engine > No Image Handling in Transformations View modes: 
User avatar
Member
Member
Rene 7 - 2/12/2012 5:11:40 PM
   
No Image Handling in Transformations
Dear Kentico,
in Kentico 5 we used to handle empty image fields (of document type file) like this:

<%# IfEmpty( Eval("picture"), "", "<div style=\"float: left; padding: 10px 20px 20px 6px; margin: 0 20px 0 0; background: #FFF;\">" + GetImage("picture", 120) + "</div>" ) %>

If the the picture field is empty it would not show the whole container (needed for styling). This does not work in Kentico 6, I believe the difference is instead of an empty field in the database, there is a sequence of zeros now like 0000000000-0000-00000

What would be the transformation in Kentico 6 to make this work?

Cheers

User avatar
Member
Member
kentico_michal - 2/13/2012 7:11:13 AM
   
RE:No Image Handling in Transformations
Hello,

The Upload file control should store the empty string instead of empty Guid. Regrettably, this is a bug that was already reported and it should be fixed in the next hotfix (6.0.18) of Kentico CMS. I am sorry for this inconvenience.

Best regards,
Michal Legen

User avatar
Certified Developer 8
Certified Developer 8
Jiveabillion - 2/16/2012 12:12:56 PM
   
RE:No Image Handling in Transformations
You could use the IfImage(guidcolumn,ifimage,ifnotimage) method in the mean-time.

also, you could wrap your markup in an <asp:PlaceHolder control to make it so you don;t have to escape quotes and things.

Here is an example:

<asp:PlaceHolder runat="server" Visible="<%# Convert.ToBoolean(IfImage("picture",true,false)) %>">
<div style="float: left; padding: 10px 20px 20px 6px; margin: 0 20px 0 0; background: #FFF;">" <%# GetImage("picture", 120) %></div>
</asp:PlaceHolder>


Remember that an ASCX transformation is really just a user control, so you can use much of the code that you would normally use in a user control. You can even have <script runat="server"> to place methods and event handlers.