Documentation Center

Determining Component Presentations programmatically

You may want to add custom criteria to determine the main Component Presentation displayed on a page.

To determine the main Component Presentation programmatically, you need create a Template Building Block containing a C# code fragment that contains logic to work out and return the Component TCM:URI and Component Template TCM:URI (separated by a comma). For example:

string result = "tcm:10-439, tcm:10-427-32";

Item packageItem = package.CreateStringItem(ContentType.Text, result);
package.PushItem("SmartTargetMainComponentPresentation", packageItem);