Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > Customizing layout of related documents control View modes: 
User avatar
Member
Member
Armysniper89 - 8/30/2010 2:16:45 PM
   
Customizing layout of related documents control
I want to leverage the related documents feature of Kentico but the related documents web part only displays links of the articles. I want to create a custom layout for it that will display the teaser text of each article in addition to the link...how would I gain access in the layout for the control to the teaser text?

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 8/31/2010 7:09:14 AM
   
RE:Customizing layout of related documents control
Hi,

you can modify CMS.Root.relateddocuments transformation used in Related Document webpart following way. This will work only for document of cms.article type. You will also need to modify cms.article.default transformation or create a new one (if you are using cms.article.default transformation somewhere else) to display only teaser text.

<strong><a href="<%# ResolveUrl(GetUrl( Eval("NodeAliasPath"), null)) %>">
<%# Eval("DocumentName") %></a></strong>
<br />

<cc1:CMSDataList ID="CMSDataList1" runat="server" ClassNames="cms.article" Path='<%# Eval("NodeAliasPath") %>'

TransformationName="cms.article.default" RepeatColumns="2" >

</cc1:CMSDataList>

<script runat="server">
protected void Page_PreRender(object sender, EventArgs e)
{
CMSDataList1.ReloadData(true);
}
</script>


Best regards,
Ivana Tomanickova

User avatar
Member
Member
Armysniper89 - 9/9/2010 12:20:19 PM
   
RE:Customizing layout of related documents control
I created a new transformation for the Root document type that looks like this:


<strong><a href="<%# ResolveUrl(GetUrl( Eval("NodeAliasPath"), null)) %>">
<%# Eval("DocumentName") %>
</a></strong><br />
<cc1:CMSDataList ID="CMSDataList1" runat="server" ClassNames="cms.article" Path='<%# Eval("NodeAliasPath") %>'TransformationName="cms.article.GreatGivingRelatedArticles" RepeatColumns="2" >
</cc1:CMSDataList>
<script runat="server">
protected void Page_PreRender(object sender, EventArgs e){CMSDataList1.ReloadData(true);}
</script>


I then created a transformation in the CMS.Article type called GreatGivingRelatedArticles that looks like this:

<H3>Related Content</H3>
<p><%# Eval("ArticleTeaserText") %></p>
<a href="<%# GetDocumentUrl() %>">Read more ></a>


The transformation for the Articles piece works, because I can use it on an ArticleList web part with no issues. How can I get this to work with your code? All I see is the H3 from the transformation and the Read More href. No teaser.

User avatar
Member
Member
Armysniper89 - 9/14/2010 1:20:47 PM
   
RE:Customizing layout of related documents control
Anything?

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 9/15/2010 11:25:33 AM
   
RE:Customizing layout of related documents control
Hi,

your code was working for me. I only need to reformat it:


<strong><a href="<%# ResolveUrl(GetUrl( Eval("NodeAliasPath"), null)) %>">
<%# Eval("DocumentName") %></a></strong>
<br />

<cc1:CMSDataList ID="CMSDataList1" runat="server" ClassNames="cms.article" Path='<%# Eval("NodeAliasPath") %>'

TransformationName="cms.article.GreatGivingRelatedArticles" RepeatColumns="2" >

</cc1:CMSDataList>

<script runat="server">
protected void Page_PreRender(object sender, EventArgs e)
{
CMSDataList1.ReloadData(true);
}
</script>


I tested functionality on Examples - Listing and Viewers - Related Documents (default Corporate site). I added article to related documents (in Properties of document) and TeaserText was displayed correctly.

In your case GreatGivingRelatedArticles transformation shows some data (H3, Read More). It means that root transformation found some documents of cms.article type.

1. If ArticleTeaserText was not displayed it could be empty. Could you please verify it?
2. Could you please check if ArticleTeaserText column exists in cms.article document type?
3. Could you please insert following code into GreatGivingRelatedArticles tranformation for testing purposes.
<p>Document name: <%# Eval("DocumentName") %></p>
4. What was the URL created in Read More> link?

Best regards,
Ivana Tomanickova