Portal Engine Questions on portal engine and web parts.
Version 4.x > Portal Engine > Repeater transformation macro View modes: 
User avatar
Member
Member
sandrews-ecentricarts - 12/7/2009 1:12:40 PM
   
Repeater transformation macro
Hello,

I'm a little stuck, hopefully someone can help me out here.

I'm trying to loop through a folder containing documents using a repeater. Now in this folder are a bunch of different document types. What I'm trying to do is use each document's default transformation.

eg.

DocumentTypeA using transformation DocumentTypeA.Default
DocumentTypeB using transformation DocumentTypeB.Default
DocumentTypeC using transformation DocumentTypeC.Default

What I've been trying to do is use a macro for the transformation field in the repeater.

e.g {%currentdocument.documenttype%}.Default

I can't seem to reference the document type of the documents being looped through. I can only seem to access the document type of the current page.

Perhaps I'm going about this wrong. Any help would be appreciated

Thanks

User avatar
Kentico Consulting
Kentico Consulting
kentico_mirekr - 12/8/2009 2:53:28 AM
   
RE:Repeater transformation macro
Hi,

I would recommend you to create one preview transformation for all of your document types. You can use this transformation in “Transformation” property of your repeater web part. Then you can use macro expression for your Selected Item transformation. Example:

Selected item transformation: {%classname%}.default

Best regards,
Miroslav Remias.

User avatar
Member
Member
sandrews-ecentricarts - 12/8/2009 8:54:39 AM
   
RE:Repeater transformation macro
Thanks for the response Miroslav.

It doesn't seem to work for me though. I'm only getting what is displayed under the preview transformation, even if I don't use the macro and use a standard transformation for the selected item transformation.

I always thought the selected item transformation was for when a user clicks on one of the items to see a detailed view, like a news story or an image gallery.

Thanks again.
Shawn

User avatar
Member
Member
sandrews-ecentricarts - 12/10/2009 1:35:38 PM
   
RE:Repeater transformation macro
Well I couldn't figure it out using macros. I ended up creating a custom usercontrol that takes the path of the folder and creates a repeater for each item in the folder, and applies the default transformation while creating it.


protected override void OnInit(EventArgs e)
{
base.OnInit(e);

string path = "/Path/to/folder/%";

TreeProvider tp = new TreeProvider();
DataSet nodes = CMS.CMSHelper.TreeHelper.SelectNodes(path, true, "", "", "NodeOrder", 1, true);

DataTable tbl = nodes.Tables[0];
int counter = 0;
foreach (DataRow dRow in tbl.Rows)
{

CMSRepeater repeater = new CMSRepeater();
repeater.Path = (string)dRow["NodeAliasPath"];
repeater.ClassNames = (string)dRow["ClassName"];
repeater.TransformationName = (string)dRow["ClassName"]+".Default";
repeater.ID = "Col1Repeater"+ counter;

this.Controls.Add(repeater);

counter++;

}

}


User avatar
Kentico Consulting
Kentico Consulting
kentico_mirekr - 12/15/2009 8:05:27 AM
   
RE:Repeater transformation macro
Hi,

Selected item transformation is mentioned for detail pages (Transformation used in the detail view mode.). This transformation is used when user clicks for example on one item displayed by the repeater. Repeater will then use transformation which is specified in “Selected item transformation:” property. The only requirement here it that the detail page should use the same repeater web part, in other words, the selected page/document should inherit page template from its parent page and this page template should contain the same repeater web part. There is no easy way how to change transformation for each item (according to its document type) which is currently displayed by repeater in List mode (when Transformation property is used). However, I’m glad that you have managed to find some workaround for this request.

Best regards,
Miroslav Remias.