Portal Engine Questions on portal engine and web parts.
Version 7.x > Portal Engine > Multiple document types displayed with one repeater View modes: 
User avatar
Member
Member
Jon White - 1/6/2014 10:33:54 AM
   
Multiple document types displayed with one repeater
I know this may have been covered before but is there a way to display a range of document types within one repeater or some such list?

I want to show an update list on the site for any articles, press releases, events etc...

I have them as all different doc types, I have seen mentioned about a universal viewer but i don't understand how this works.

I have also seen an article about changing field names using an SQL Query and Union/aliasing to somewhat 'generalise' the names of all the doc type fields so a basic transformation would pull in the data across all doc types, but i couldn't get this to work.

Can anyone advise what the best solution is for this?

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 1/6/2014 11:10:33 AM
   
RE:Multiple document types displayed with one repeater
For your transformations you can simply use the {%ClassName%} macro. Assuming you have the same Transformation name for every document type you want to display. For instance {%ClassName%}.Preview which would render as CMS.News.Preview for news events and CMS.Article.Preview for articles. If you're doing any WHERE or ORDER BY statements you might need to do IF statements with your macro for the class.

User avatar
Member
Member
Jon White - 1/7/2014 4:56:36 AM
   
RE:Multiple document types displayed with one repeater
Hi there, thanks for the info I think this would work although i have added it to the transformation and it says:

Transformation 'CMS.MenuItem.Preview' not found.

Can you assist me further?

Thank you in advance

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 1/7/2014 7:21:50 AM
   
RE:Multiple document types displayed with one repeater
What are the doc types you are using? For instance if you have:

CMS.Event
CMS.News

You will need to go to each one of those doc types and create a transformation with the same name, in this case we'll call it "Preview". So your macro in the repeater property will be {%ClassName%}.Preview. If you don't have this transformation in the doc type you will receive the error you are experiencing now.

User avatar
Member
Member
Jon White - 1/7/2014 8:31:49 AM
   
RE:Multiple document types displayed with one repeater
Hi there,

All the doc types I need have the 'Preview' transformation in them.

So i have :

CMS.News .Preview
CMS.Event .Preview
CMS.Project .Preview
etc...

I am using a repeater to display a bunch of selected doc types with:

'{%ClassName}.Preview' in the transformation box.

Now all this does is display the 'CMS.Root .Preview' transformation over and over but i've deselected this in the document types option?!

Am i doing this all wrong? Just to add that this is on the master page, so it will be displayed on all pages but the home page.

Thank you

User avatar
Member
Member
Jon White - 1/12/2014 5:01:07 PM
   
RE:Multiple document types displayed with one repeater
Ignore my error in code above, even with the % it doesn't work.

I assume that the 'classname' macro doesn't 'bring in' all of the transformations? Maybe just the type it is?

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 1/12/2014 6:03:46 PM
   
RE:Multiple document types displayed with one repeater
Sorry about that, I didn't even notice the code until I looked again. Your macro should read
{%ClassName%}.<TransformationName>
The problem with what you entered was {%ClassName} wouldn't return anything because it didn't have the closing %.

The macro "ClassName" won't do anything with transformations, it simply is a dynamic property based on the document being rendered at the time. If you were to look at the fully rendered text, it would be something like
cms.article.previewlist
OR
cms.news.previewlist
The value "previewlist" is the actual code name you give it when you create it in the document types transformation tab.

User avatar
Member
Member
Jon White - 1/21/2014 4:23:22 AM
   
RE:Multiple document types displayed with one repeater
Hi (again!),

I've used the above transformation, the issue i have is that the repeater is used on the 'root'/master page (as i want it to appear on every page) and only seems to be pulling in the transformation of 'ROOT.Preview', none of the others. You have said above that it is based on the document being loaded at the time, but is there a way to include all doc types?

Have i missed out something obvious here? I really want this to work as a 'recent updates' feed on my site so i'm desperate but maybe this can't be done in this way.

Thank you for your assistance

User avatar
Certified Developer 10
Certified Developer 10
josha-bpstudios - 1/21/2014 10:53:32 AM
   
RE:Multiple document types displayed with one repeater
Have you specified document types for the repeater to load? If you wanted all, then theoretically every doctype would have to have a preview transformation maybe? Try setting the repeater doc type to just the ones that you wanted and also the ones that you have a preview transformation for.

User avatar
Member
Member
Jon White - 1/21/2014 10:58:42 AM
   
RE:Multiple document types displayed with one repeater
Hi there,

Yes i've chosen only a select few doc types. not including 'CMS.Root'.

So i don't know why it's loading the 'CMS.Root.preview' transformation.

All the doc types have a ####.Preview titled transformation.

Thanks
Jon

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 1/21/2014 11:02:42 AM
   
RE:Multiple document types displayed with one repeater
Have you turned on debugging to see what the query is that is being ran? There's a good change this will expose the issue vs. attempting to guess.