ASPX templates
Version 4.x > ASPX templates > CMSRepeater and Multiple Classnames and Multiple Transformations View modes: 
User avatar
Member
Member
byron-falcon-software - 7/3/2009 11:06:21 AM
   
CMSRepeater and Multiple Classnames and Multiple Transformations
I have a repeater than needs to show both cms.news and cms.events together.

So I added the class name to the ClassNames properties. Of course, without the transformation for events, none of them showed, so I tried to add them the way I added the class names, but then I got nothing:
<cms:CMSRepeater ID="CMSRepeater1" ClassNames="cms.news;cms.event" TransformationName="cms.news.preview;cms.event.preview" SelectedItemTransformationName="cms.news.default;cms.event.default" runat="server" Path="/%" />

Is there are way to use multiple classes and multiple transformations or do I need to do this another way?

User avatar
Member
Member
bluerhino_avanmeter - 7/6/2009 9:48:40 AM
   
RE:CMSRepeater and Multiple Classnames and Multiple Transformations
You'll have to create a workaround because you can't have two transformations applied to one repeater (as far as I know).

There are a couple different routes you can go.

1) You can use the TreeEngine.TreeProvider to get a dataset of the news and event documents and then build the display yourself.

Dim tree As New CMS.TreeEngine.TreeProvider(CMSContext.CurrentUser)
Dim ds As Data.DataSet = _
tree.SelectNodes(CMSContext.CurrentSiteName, "/%", _
CMSContext.CurrentDocumentCulture.CultureCode, _
True, "cms.news;cms.events")
ds = CMS.TreeEngine.TreeSecurityProvider.FilterDataSetByPermissions(ds, _
CMS.TreeEngine.NodePermissionsEnum.Read, CMSContext.CurrentUser)

2) You can create one 'default' and one 'selected item' transformation for displaying properties of both news and events (i.e. cms.news.previewNewsAndEvents), using the IfEmpty transformation method to determine what to display. This gets pretty difficult if you're trying to do anything beyond a very simple display of the document data.

User avatar
Member
Member
byron-falcon-software - 7/14/2009 11:11:30 AM
   
RE:CMSRepeater and Multiple Classnames and Multiple Transformations
This code gives me this error:

[GeneralConnection.RunQuery]: Query 'cms.events.selectdocuments' not found.

However, looking at the Site Manager for the document type, the query does exist and in enabled for my site.

I have applied the .10 hotfix. Does this work for you?

User avatar
Member
Member
byron-falcon-software - 7/14/2009 11:43:30 AM
   
RE:CMSRepeater and Multiple Classnames and Multiple Transformations
cms.event not cms.events.

User avatar
Member
Member
byron-falcon-software - 7/14/2009 11:50:05 AM
   
RE:CMSRepeater and Multiple Classnames and Multiple Transformations
And I still only get one News Result and no events and the repeater on that page gets them all, 4 news and 2 events.

User avatar
Member
Member
bluerhino_avanmeter - 7/14/2009 12:10:05 PM
   
RE:CMSRepeater and Multiple Classnames and Multiple Transformations
Are you using workflow (i.e. publishing of documents)? That may cause documents to not show up. If I remember correctly, the repeater includes unpublished documents by default and the TreeEngine node search does not.

Also, you may not need the ApplySecurityPermissions part of that code. Is this a public site or one with authentication? If it's public, you don't need that part.

User avatar
Member
Member
byron-falcon-software - 7/14/2009 12:10:23 PM
   
RE:CMSRepeater and Multiple Classnames and Multiple Transformations
My bad, didn't set Join Current Culture to true.

User avatar
Kentico Consulting
Kentico Consulting
kentico_mirekr - 7/6/2009 11:09:49 AM
   
RE:CMSRepeater and Multiple Classnames and Multiple Transformations
Hi,

You can use multiple classes in repeater web part property (ClassNames), but you can use only one transformation. However, you can check in your transformation if current document is your news document or your event document according to its fields using following example code:

<%# IfEmpty( Eval("FileName"), Eval("NewsTitle") , Eval("FileName")) %>

If FileName field of CMS.File is available it is displayed, otherwise NewsTitle is displayed.

Or you can create your own transformation function that would return your desired data from the input data if the context of the document is available.

Best Regards,
Miroslav Remias

User avatar
Member
Member
byron-falcon-software - 7/13/2009 3:03:44 PM
   
RE:CMSRepeater and Multiple Classnames and Multiple Transformations
How do I sort by NewsReleaseDate or the EventDate?

User avatar
Kentico Consulting
Kentico Consulting
kentico_mirekr - 7/13/2009 3:47:56 PM
   
RE:CMSRepeater and Multiple Classnames and Multiple Transformations
Hi,

For this purpose repeater web part has “ORDER BY expression:” property where you can specify according which fields should be the data ordered.

Best Regards,
Miroslav Remias

User avatar
Member
Member
byron-falcon-software - 7/13/2009 4:41:19 PM
   
RE:CMSRepeater and Multiple Classnames and Multiple Transformations
Thanks for the reply, the problems are two fold with that:

1) There are two document types are work here, CMS.News and CMS.Events
2) The two columns I need to sort on do not exist in both. The Order By Appears to be appended to the SQL, so that "NewsReleaseDate DESC,EventDate DESC" throws an error for News because EventDate is not part of the View it calls and would and would throw an error for Events because NewReleaseDate doesn't exist in the Events view.

Each are called separately and then joined, it is likely I need to the same thing but some other way so that I can sort on boththe NewsReleaseDate and EventDate to display them together as one listing.

User avatar
Kentico Developer
Kentico Developer
kentico_martind - 7/28/2009 8:50:55 AM
   
RE:CMSRepeater and Multiple Classnames and Multiple Transformations
Hello,

Unfortunately, this scenario is not supported with CMSRepeater, but you can use QueryRepeater and write custom query to retrieve data. Basically you will need to make left join of CMS_Tree, CONTENT_news and CONTENT_Event tables so the columns that are not defined for appropriate row (e.g. NewsReleaseDate for row from CONTENT_Event) are filled with nulls and then you should be able to order joined rows by NewsReleaseDate and EventDate.

Best Regards,

Martin Dobsicek

User avatar
Kentico Support
Kentico Support
kentico_zdenekc - 7/14/2009 8:48:57 PM
   
RE:CMSRepeater and Multiple Classnames and Multiple Transformations
Hi,

just a little addition to multiple transformations:

You could have multiple transformations in repeater thanks to macro expression, e.g.:

{ClassName}.mytransformation

- the transformation name has to be same for all document types.

Regards,
Zdenek C.

User avatar
Member
Member
sysadmin-xcomms - 3/11/2010 6:18:50 AM
   
RE:CMSRepeater and Multiple Classnames and Multiple Transformations
Sorry for dragging this up, but {ClassName}.mytransformation doesnt seem to work.

Is this only available to the portal engine users? If yes, is there any workaround on the horizon for ASPX implementations?

User avatar
Kentico Developer
Kentico Developer
kentico_martind - 3/21/2010 2:34:47 PM
   
RE:CMSRepeater and Multiple Classnames and Multiple Transformations
Hello,

Regrettably this macro is not supported in ASPX templates. You can check document type of current document and set transformation manually. Please find sample code bellow:



if (CMS.CMSHelper.CMSContext.CurrentPageInfo.ClassName.ToLower() == "cms.news")
{
repItems.TransformationName = "nameOfTransformationForCMS.News";
}
else if (CMS.CMSHelper.CMSContext.CurrentPageInfo.ClassName.ToLower() == "cms.article")
{
repItems.TransformationName = "nameOfTransformationForCMS.Article";
}
repItems.ReloadData();


Best Regards,

Martin Dobsicek

User avatar
Member
Member
wensveen-evident - 8/10/2011 9:44:34 AM
   
RE:CMSRepeater and Multiple Classnames and Multiple Transformations
Hi,
I know this is quite an old thread, but the problem remains. The {%ClassName%}.MyTransformation macro works but ClassName resolves to the ClassName of the document the repeater is used in and not the document the repeater is currently displaying.

Is there another expression I can use to get the current document of the repeater? Something like {%Node.ClassName%}

Macro expressions are still a bit of a mystery to me (partly due to lack of a *complete* reference)...

Thanks,
Matthijs Wensveen

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 8/11/2011 5:54:24 AM
   
RE:CMSRepeater and Multiple Classnames and Multiple Transformations
Hi,

The macro is resolved according to your description, but the macro has to be inserted in the Selected item transformation property. Then the class name is resolved according to the displayed node, not the node on which is repeater inserted. Please take a look at Products section on a default Corporate site to see the working example.

Best regards,
Ivana Tomanickova

User avatar
Member
Member
wensveen-evident - 8/11/2011 7:23:26 AM
   
RE:CMSRepeater and Multiple Classnames and Multiple Transformations
Aaah, thanks. That makes sense.

Regards,
Matthijs

User avatar
Member
Member
fabio-inorbital - 1/7/2011 2:13:43 PM
   
RE:CMSRepeater and Multiple Classnames and Multiple Transformations
Hi there,

I'm in the same situation, trying to get my web-part to work with multiple document types and transformations.

I'm trying the proposed workaround/solutions but I'm facing a problem. The curent document is always returning as if it is a MenuItem.. so I can't get to differentiate what is even and what is news.

Any thoughts and help is appreciated.

User avatar
Kentico Developer
Kentico Developer
kentico_ondrejv - 1/14/2011 8:43:27 AM
   
RE:CMSRepeater and Multiple Classnames and Multiple Transformations
Hello,

What version of Kentico CMS are you using? Any hotfixes?

What particular solution are you trying, that one for ASPX templates? If so, could you please send me over your code to support@kentico.com (preferably the whole page template)?

Are you completely sure that your documents are not of type Page menu item?

Would it be possible to grant me an access to your live site (if any), so that I could inspect it further? Please point me to appropriate location. You can send credentials via e-mail as well.

Best regards
Ondrej Vasil

User avatar
Member
Member
eagleag - 3/6/2011 2:46:58 PM
   
RE:CMSRepeater and Multiple Classnames and Multiple Transformations
in webpart cs file:

// Transformation properties
this.repItems.TransformationName = this.TransformationName;

"this.TransformationName" cant be multiple transformation names,
So where can I add custom code checking for each document that repeating and dynamically choosing correct transformation for each document type that repeating?

THANKS:)

User avatar
Kentico Developer
Kentico Developer
kentico_ondrejv - 3/9/2011 4:13:14 PM
   
RE:CMSRepeater and Multiple Classnames and Multiple Transformations
Hello,

In fact, you won't change the transformation, but will retrieve string which is relevant to given document type. You can check the document type in your custom function: http://devnet.kentico.com/docs/devguide/adding_custom_functions_to_transformations.htm in the transformation and retrieve particular string according to actual document type.

Best regards
Ondrej Vasil

User avatar
Member
Member
wensveen-evident - 8/23/2011 3:25:45 PM
   
RE:CMSRepeater and Multiple Classnames and Multiple Transformations
Am I right in assuming this problem will can be solved in Kentico 6 with a Universal Viewer component?

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 8/24/2011 2:33:38 AM
   
RE:CMSRepeater and Multiple Classnames and Multiple Transformations
Hi,

Yes, you are right :-)

Best regards,
Juraj Ondrus