Welcome to the Learning Center

The Guide | Knowledge Base | FAQ

Browse it all or refine your selection using the filters below on the left.

Using More Than One Template In An XMod Pro Module

An example of using multiple templates in one XMod Pro module

By: Angus Beare On: 11/03/2010

Link to this Article
https://dnndev.com/Learn/Guide/Article/Using-More-than-one-template-in-an-XMod-Pro-Module

A great feature of XMod Pro is that you can add as many templates as you like to your module. This feature can come in very handy at times. XMod Pro also lets you send data between templates giving your the ability to demonstrate relationships between your data.

Consider that you want to display staff from three different departments and you want each department to have a unique header. You might build something with the framework like this. Where there is a template for each department. Each template has it’s own SQL call and shows different data.


<xmod:Template id="HeadofDepartment"> 
</xmod:Template>
<xmod:Template id="FinanceandAdmin">
</xmod:Template> 
<xmod:Template id="Tax">
</xmod:Template> 
<xmod:Template id="HumanResource">
</xmod:Template> 

The multiple template feature is also useful if you want a simple way to show a record count or if you want to show a link to more data only when there is more than the current page shows.

For example, this template is used at the foot of a page. It counts the number of records and shows a link when the count is greater than the page size.


<xmod:Template UsePaging="False" id="count">

<ListDataSource CommandText="
SELECT count(*) as numrows
FROM DMX_Entries DMXE 
inner join DMX_ShortTexts DMXST 
on DMXE.EntryID=DMXST.ObjectId and SubTypeKey='TITLE' 
inner join DMX_Extensions DMXEXT on DMXE.EntryType=DMXEXT.ExtensionKey
/* get the remarks if they exist - gus 21-4-2010 */
left outer join DMX_LongTexts DMXLT on DMXLT.ObjectId= DMXE.EntryID and DMXLT.SubTypeKey='REMARKS'
and DMXLT.TypeKey='ENT'
 
where entryID=LastVersionID 
and deleted=0
and DMXE.EntryType <> 'Collection'
and collectionID=@collectionID">

	<Parameter name="collectionID" value='[[Module:collectionID]]'/>
</ListDataSource>

<ItemTemplate>
<xmod:Select>

   <Case CompareType="numeric" operator=">" value='[[numrows]]' expression="12">
   	<xmod:Redirect text="Show More Documents" target="/EEIOCGmember/MoreMeetingDocumentsEEIOCG.aspx">
   		<Field name="collectionID" value='[[Module:collectionID]]' />
   	</xmod:Redirect>
   </Case>
   
</xmod:Select>
</ItemTemplate>
    
</xmod:Template>

If there are more than 12 rows, the user will see a link to a page with the full list of documents. The above would also be useful for showing a record count at the foot of a list.