Pagelets explained Foundation
While layouts are used to give different CXP pages the same structure and for sharing content, pagelets are like functions. Pagelets act like independent HTML content and provide discrete access to this content. Pagelets can be included in any number of pages or layouts. Also, pagelets can be used for breaking up complex pages into smaller reusable units.
A pagelet can be included in the calling page via the :renderPage() method as shown below. The first parameter is the relative URL of the CXP page implementing the pagelet. Subsequent parameters provided in the call are simply passed on to the pagelet, and can be retrieved using PValue()/PCount() or via the :params collection of the CXP page.
<!-- main.cxp -->
<h1>Random collection of quotes!</h1>
<%
FOR n:=1 TO 5
::RenderPage(".\pagelet.cxp", "Quote #"+AllTrim(Str(n))+" of the day!" )
NEXT n
%>
<!-- pagelet.cxp -->
<%
aTips := {}
AAdd( aTips, {"One of my most productive days was throwing away 1000 lines of code.","Ken Thompson" } )
AAdd( aTips, {"Simplicity is the ultimate sophistication.","Leonardo da Vinci"} )
AAdd( aTips, {"Controlling complexity is the essence of computer programming.","Brian Kernigan"} )
AAdd( aTips, {"Simplicity is prerequisite for reliability.","Edsger W. Dijkstra"} )
AAdd( aTips, {"The crazier the theory, the more likely it is to be correct.","Niels Bohr"} )
nIdx := RandomInt(1,Len(aTips))
cTitle := PValue(1)
%>
<div style="font-family: 'Segoe UI Light', 'Segoe UI', Verdana, Arial, Helvetica;font-size:9pt;color:white;background-color:#efefef;width:20em;padding:0px;margin:0px;">
<h1 style="background-color:#13346e; color:#efefef;padding-left:5px;font-size:11pt; margin-bottom:5px;" >@(cTitle)</h1>
<div style="padding-left:5px; padding-top:2px; padding-bottom:2px; padding-right:1px;color:#13346e;">
<a href="#" style="text-decoration:none">
@(aTips[nIdx][1])<br>
<small>@(aTips[nIdx][2])</small>
</a>
</div>
<div style="margin:0px 0px 1px 0px"> </div>
</div>
If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.