Output image in CMSRepeater ItemTemplate

Tom F asked on December 1, 2016 00:28

Hi all, I'm trying to output an image uploaded from a page type file input in a CMSRepeater.

I'm trying to do this directly in an aspx page. so the ascx transform helpers don't exist.. I'm not sure I'm going about it the right way but I can't find any documentation.

Just wondering what I'm missing as I can't find <%# GetImage in v10 and I can't find any documentation on it.

 <cms:CMSPagePlaceholder ID="plcZones" runat="server">
                        <LayoutTemplate>
                            <cms:CMSRepeater ID="PointsOfDifferenceRepeater" ClassNames="EnvoyTravelTechnologies.PointOfDifference" EnablePaging="false" runat="server">
                                <ItemTemplate>
                                    <%# (Container.ItemIndex + 4) % 4 == 0 ? "<div class=\"row" + (Container.ItemIndex == 0 ? " first-point-of-difference-row\"" : " nth-point-of-difference-row\"") + ">" : string.Empty %>
                                    <div class="col-lg-3 col-md-12 col-sm-12 col-xs-12 point-of-difference-container">
                                        <img alt="<%# Eval("DocumentName") %>" src="<%# MediaLibraryFunctions.GetMediaFileUrl(Eval("Image"), "Image") %>" />
                                        <asp:Image ID="Image" runat="server" />
                                        <h3><%# Eval("Title") %></h3>
                                        <div class="description"><%# Eval("Description") %></div>
                                    </div>
                                    <%# (Container.ItemIndex + 4) % 4 == 3 ? "</div>" : string.Empty %>
                                </ItemTemplate>
                            </cms:CMSRepeater>
                        </LayoutTemplate>
                        </cms:CMSPagePlaceholder>

Thanks, Tom

Correct Answer

Anton Grekhovodov answered on December 1, 2016 05:18

Hi Tom,

All transformation helpers exist in TransformationHelper.HelperObject object (from CMS.Controls namespace).

Short name GetImage(...) is just for Transformations inside Kentico.

2 votesVote for this answer Unmark Correct answer

Recent Answers


Tom F answered on December 1, 2016 05:51

Thanks Anton, Most appreciated :)

Generally do people use aspx templates and build up web parts/transformations or do they deal with the data like I have above? I'm trying to work out what best practice/preferred convention is..

0 votesVote for this answer Mark as a Correct answer

Anton Grekhovodov answered on December 1, 2016 06:18

Firstly, you need to understand difference between webparts/widgets/ascx user controls/transformations and other entities)
Webparts are Kentico components base on acsx control or another webpart which you place in template
Widgets are Kentico components too, but they are base on webparts and they have another purpose
Transformations are code templates that determine how listing web parts and controls render content (in general)

Usually we use Portal Engine development model (it has its own advantages and disadvantages), it means we don't have any aspx pages. All templates we store in Kentico. And we create custom webparts for these templates with our own HTML markup.

0 votesVote for this answer Mark as a Correct answer

Tom F answered on December 1, 2016 06:23

I can see how that would work really well but what about handling complex visibility logic? is that all contained in a transformation of a given webpart?

0 votesVote for this answer Mark as a Correct answer

Anton Grekhovodov answered on December 1, 2016 06:55

Tom,

You can implement visibility logic in different ways: transformations (in Kentico), ascx item templates (as you did in your example), mustashe/handlebars templates. Also each webpart has some properties like HTML container and HTML before/after, you can use them too.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.