Visitor interaction

There are for way to handle user clicks and other actions:
To demonstrate visitor interaction I create a pageable list of desktop modules with selectable page size. To let search engines navigate pages of list we setup pages as URL parameters. Page size in not required to be SEO-friendly, so we use ajax to change it.

First we need a stored procedure to retrieve list of modules. As we want to have the list pageable, we have to introduce current page number and page size parameters.

create procedure {databaseOwner}[{objectQualifier}mdo_xslt_modules] @PortalID int, @PageNumber int, @PageSize int as
begin
   select * from (
	select ROW_NUMBER() over(order by FriendlyName) rownum, *
	from {databaseOwner}[{objectQualifier}DesktopModules]) t
   where rownum between (@PageNumber-1)*@PageSize+1 and @PageNumber*@PageSize;

   select count(*) as [count] from {databaseOwner}[{objectQualifier}DesktopModules];
end;
Note, procedure returns 2 result sets: current page and total number of rows. Now build a simple pageable list:

<!-- assign variables to simplify xsl code -->
<xsl:variable name="page" select="mdo:param('$page', 1)" />
<xsl:variable name="modules" select="mdo:xml('modules', 'dm, count', $page, 10)" />

Total count of rows: {{$modules/root/count/count}}<br />
Current page: {{$page}}
<br /><br />
<a href="{mdo:navigate('$page', $page - 1 )}">PREV</a> |
<a href="{mdo:navigate('$page', $page + 1 )}">NEXT</a>
<br /><br />
<xsl:for-each select="$modules/root/dm">
  {{FriendlyName}}<br />
</xsl:for-each>
Note, as we have two SELECTs in stored procedure we pass 2 entity names in the 2-nd parameter of mdo:xml. If you want to want paging to use ajax just cange mdo:navigate to mdo:jajax.

Now add a page size selector. Assume we have 3 page sizes allowed 5, 10 and 15 rows.

<!-- assign variables to simplify xsl code -->
<xsl:variable name="page" select="mdo:param('$page', 1)" />
<xsl:variable name="pagesize" select="mdo:param('$pagesize', 10)" />
<xsl:variable name="modules" select="mdo:xml('modules', 'dm, count', $page, $pagesize)" />

Total count of rows: {{$modules/root/count/count}}<br />
Current page: {{$page}}
<br /><br />
<a href="{mdo:navigate('$page', $page - 1 )}">PREV</a> |
<a href="{mdo:navigate('$page', $page + 1 )}">NEXT</a> |
Select page size:
<a href="{mdo:jajax('$pagesize', 5)}">[5]</a>,
<a href="{mdo:jajax('$pagesize', 10)}">[10]</a> or
<a href="{mdo:jajax('$pagesize', 15)}">[15]</a>
records per page.
<br /><br />
<xsl:for-each select="$modules/root/dm">
  {{FriendlyName}}<br />
</xsl:for-each>
Note, that we mix ajax and URL parameters methods seamles without any additional coding.

Last edited Nov 17, 2009 at 9:20 AM by findy, version 4

Comments

No comments yet.