Welcome to the Learning Center

The Guide | Knowledge Base | FAQ

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

Creating A Generic List - in XMod Pro

How to use XMod Pro's User Defined Module Settings feature to create a generic list

By: Angus Beare On: 11/03/2010

Link to this Article
https://dnndev.com/Learn/Guide/Article/Creating-A-Generic-List-in-XMod-Pro

How to use XMod Pro’s new feature of User Defined Module Settings to create a generic list.

In the last three projects I have been involved with we have been working with organisations that have a large number of committees. Each committee is required to have a page for various types of documents. These documents might be meeting documents, agendas or Minutes for example. Therefore each committee requires a list of documents filtered on the ID of the committee and the document type.

I have personally been involved with XMod Pro since beta days and I have played an active role in feature requests in many of the releases. In the early days there was no such feature as module level settings. This meant that unless the template was being called from a link where I could pass in a parameter I would have to create a unique template for every committee. For one project in particular this lead to over 200 templates which were identical apart from a couple of parameters.

You can imagine how delighted I was when user level module settings appeared in the 2.7 release back in August 2010. This feature was going to save me hours of work!  What user defined module level parameters means is that a single template can be used in all the cases where only ID’s were going to change.

So, when the first opportunity arose I couldn’t wait to test it out.

All you have to do is configure the module by adding the parameters into module settings. Then then parameters are available in the template for filtering. Here’s my first example of a generic template.


<xmod:Template>
  <ListDataSource CommandText="exec DI_GetDocuments @Cat1,@Cat2" >
  	<Parameter name="Cat1" value='[[Module:Cat1]]' />
  	<Parameter name="Cat2" value='[[Module:Cat2]]' />
  </ListDataSource>


  <HeaderTemplate>
    <table border="0" cellspacing="0" cellpadding="6" class="member_only_doc_table" >
    <tbody>
    <tr>
    	<td width="500" colspan="2" class="public_document_header" align="left" valign="bottom">Document title</td>
    	<td width="100" class="public_document_header" align="right" valign="bottom">Date</td>
    </tr>
   </HeaderTemplate>

   <ItemTemplate>
    <tr>
    	<td align="left" valign="top"><a href="/PublicDocumentDownload.aspx?Command=Core_Download&EntryId=[[EntryID]]"><img src="/[[Icon16]]" /></a>&#160;&#160;</td>
    	<td class="member_only_doctitle" align="left" valign="top"><a  href="/PublicDocumentDownload.aspx?Command=Core_Download&EntryId=[[EntryID]]">[[DocumentTitle]]</a></td>
    	<td align="right" valign="top">[[DocDay]]/[[DocMonth]]/[[DocYear]]</td>
    	<td></td>
    </tr>
    <tr>
    	<td></td>
    	<td class="member_only_remarks">[[Remarks]]</td>
    	<td></td>
    </tr>
    </ItemTemplate>
    
   <AlternatingItemTemplate>
    <tr class="rowborders">
    	<td align="left" valign="top"><a href="/PublicDocumentDownload.aspx?Command=Core_Download&EntryId=[[EntryID]]"><img src="/[[Icon16]]" /></a>&#160;&#160;</td>
    	<td align="left" valign="top" class="member_only_doctitle"><a href="/PublicDocumentDownload.aspx?Command=Core_Download&EntryId=[[EntryID]]">[[DocumentTitle]]</a></td> 
    	<td align="right" valign="top">[[DocDay]]/[[DocMonth]]/[[DocYear]]</td>
    	<td></td>
    </tr>
    <tr>
    	<td></td>
    	<td class="member_only_remarks">[[Remarks]]</td>
    	<td></td>
    </tr>
   </AlternatingItemTemplate>
    
   <NoItemsTemplate>
    	<div class="no_items_template_pp">
    	No documents were found...
		</div>
   </NoItemsTemplate>
    
   <FooterTemplate>
    </tbody>
    </table>
    
    <!-- <table class="members-only-xmp-button">
    	<tr>
    		<td>&nbsp;</td>
    	</tr>
    	<tr>
    		<td class="dmx_blue_button"><a class="" href="">See more documents</a></td>
    	</tr>
    </table> -->
   
   </FooterTemplate>
   
</xmod:Template>

Note that there are two Parameters that are passed into the template from the module settings: Cat1 and Cat2. These are then passed into a generic stored procedure that gets the documents.

This example works with the Document Exchange Professional module for secure storage of documents. For more information about how brilliant XMod Pro is at working with DMX read my other blog post: Using XMod Pro to Display Documents - with Document Exchange Professional

I hope you find this useful. Thanks for reading.

Gus