Handling Page content in code
This section explains typical scenarios related to handling Pagecontent in code and includes code samples for each scenario.
- Accessing the first Component Presentations on a Page
You can access the first Component Presentation that has been placed on a Page from your code. - Looping through all Component Presentations
If the Component Presentations on a Page are not assembled at visit time using a query, the Page contains a list of Component Presentations (pairs of a Component and its accompanying Component Template). Typically, you would want to loop through these Component Presentations to render each one. - Accessing Page metadata
You can access the metadata of a Page from code. - Accessing specific Component Presentations on a Page
If the Component Presentations on a Page are not assembled at visit time using a query, the Page contains a list of Component Presentations (pairs of a Component and its accompanying Component Template). You can access specific Component Presentations on a Page item inside a package, or on a Page in the Content Manager. - Positioning script fragments on the webpage
When turning a Page, or Dynamic Component Presentations, into a publishable webpage, SDL Tridion may insert fragments of script code into the template output during publishing. You may want to control where SDL Tridion Sites inserts the various script fragments, for example if SDL Tridion Sites puts its script fragments above your content. - .NET Page Template Building Block example
The following annotated example explains how you can write a .NET Template Building Block for a Page Template.