Fix paging on yourtopics

This commit is contained in:
Sebastiaan Janssen
2013-02-08 13:27:31 +01:00
parent 4d960eee99
commit 36da2e4e6f
2 changed files with 91 additions and 60 deletions
@@ -14,12 +14,13 @@
<xsl:param name="currentPage"/>
<xsl:variable name="p">
<xsl:variable name="recordsPerPage" select="15"/>
<xsl:variable name="pageNumber" >
<xsl:choose>
<xsl:when test="string(number( umbraco.library:RequestQueryString('p') )) != 'NaN'">
<xsl:when test="umbraco.library:RequestQueryString('p') &lt;= 0 or string(umbraco.library:RequestQueryString('p')) = '' or string(umbraco.library:RequestQueryString('page')) = 'NaN'">0</xsl:when>
<xsl:otherwise>
<xsl:value-of select="umbraco.library:RequestQueryString('p')"/>
</xsl:when>
<xsl:otherwise>0</xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
@@ -32,9 +33,8 @@
<xsl:variable name="mem" select="umbraco.library:GetCurrentMember()/@id"/>
<xsl:variable name="items">15</xsl:variable>
<xsl:variable name="pages" select="uForum:MemberTopicPager($mem, $items, $p)"/>
<xsl:variable name="topics" select="uForum.raw:TopicsWithParticipation($mem,$items, $p)//topic"/>
<xsl:variable name="pages" select="uForum:MemberTopicPager($mem, $recordsPerPage, $pageNumber)"/>
<xsl:variable name="topics" select="uForum.raw:TopicsWithParticipation($mem, $recordsPerPage, $pageNumber)//topic"/>
<table cellspacing="0" class="forumList">
@@ -48,70 +48,66 @@
<tbody>
<xsl:for-each select="$topics">
<tr id="topic{@id}">
<xsl:if test="answer != 0">
<xsl:attribute name="class">solved</xsl:attribute>
</xsl:if>
<tr id="topic{@id}">
<xsl:if test="answer != 0">
<xsl:attribute name="class">solved</xsl:attribute>
</xsl:if>
<th class="title">
<a href="{uForum:NiceTopicUrl(id)}">
<xsl:value-of select="title"/>
</a>
<small>
Started by: <xsl:value-of select="umbraco.library:GetMemberName(memberId)" />
- <span title="{umbraco.library:FormatDateTime(created, 'MMMM d, yyyy @ hh:mm')}">
<xsl:value-of select="uForum:TimeDiff(created)"/>
</span>
<xsl:if test="answer != 0">
<em>&nbsp; - Topic has been solved</em>
</xsl:if>
</small>
</th>
<td class="replies">
<xsl:value-of select ="replies"/>
</td>
<td class="latestComment">
<a href="{uForum:NiceTopicUrl(id)}" title="{umbraco.library:FormatDateTime(updated, 'MMMM d, yyyy @ hh:mm')}">
<xsl:value-of select="uForum:TimeDiff(updated)"/>
</a> by
<th class="title">
<a href="{uForum:NiceTopicUrl(id)}">
<xsl:value-of select="title"/>
</a>
<small>
Started by: <xsl:value-of select="umbraco.library:GetMemberName(memberId)" />
- <span title="{umbraco.library:FormatDateTime(created, 'MMMM d, yyyy @ hh:mm')}">
<xsl:value-of select="uForum:TimeDiff(created)"/>
</span>
<xsl:if test="answer != 0">
<em>&nbsp; - Topic has been solved</em>
</xsl:if>
</small>
</th>
<td class="replies">
<xsl:value-of select ="replies"/>
</td>
<td class="latestComment">
<a href="{uForum:NiceTopicUrl(id)}" title="{umbraco.library:FormatDateTime(updated, 'MMMM d, yyyy @ hh:mm')}">
<xsl:value-of select="uForum:TimeDiff(updated)"/>
</a> by
<xsl:choose>
<xsl:when test="number(latestReplyAuthor) &gt; 0">
<xsl:value-of select="umbraco.library:GetMemberName(latestReplyAuthor)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="umbraco.library:GetMemberName(memberId)"/>
</xsl:otherwise>
</xsl:choose>
</td>
</tr>
<xsl:choose>
<xsl:when test="number(latestReplyAuthor) &gt; 0">
<xsl:value-of select="umbraco.library:GetMemberName(latestReplyAuthor)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="umbraco.library:GetMemberName(memberId)"/>
</xsl:otherwise>
</xsl:choose>
</td>
</tr>
</xsl:for-each>
</xsl:for-each>
</tbody>
</table>
<xsl:variable name="numberOfRecords" select="uForum.raw:CountTopicsWithParticipation($mem)//yourTopicsCount"/>
<xsl:if test="$numberOfRecords &gt; $recordsPerPage">
<strong>Pages: </strong>
<ul id="projectPager" class="pager">
<xsl:call-template name="paging.loop">
<xsl:with-param name="i">0</xsl:with-param>
<xsl:with-param name="count" select="ceiling($numberOfRecords div $recordsPerPage)"></xsl:with-param>
</xsl:call-template>
<xsl:if test="count($pages//page) &gt; 1">
<ul class="pager">
<xsl:for-each select="$pages//page">
<li>
<xsl:if test="@current = 'true'">
<xsl:attribute name="class">current</xsl:attribute>
</xsl:if>
<a href="?p={@index}">
<xsl:value-of select="@index + 1"/>
</a>
</li>
</xsl:for-each>
</ul>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<h3>Error</h3>
You have to be logged in to view your posts!
</xsl:otherwise>
</xsl:choose>
</div>
@@ -121,6 +117,29 @@
</xsl:template>
<xsl:template name="paging.loop">
<xsl:param name="i"/>
<xsl:param name="count"/>
<xsl:if test="$i &lt; $count">
<li>
<xsl:if test="$pageNumber = $i ">
<xsl:attribute name="class">
<xsl:text>current</xsl:text>
</xsl:attribute>
</xsl:if>
<a href="?p={$i}">
<xsl:value-of select="$i + 1" />
</a>
</li>
<xsl:call-template name="paging.loop">
<xsl:with-param name="i" select="$i + 1" />
<xsl:with-param name="count" select="$count">
</xsl:with-param>
</xsl:call-template>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
+13 -1
View File
@@ -44,7 +44,19 @@ namespace uForum.Library {
return Businesslogic.Data.GetDataSet(sql, "topic");
}
public static XPathNodeIterator CountTopicsWithParticipation(int memberId)
{
string sql = @"SELECT count(DISTINCT forumTopics.id)
FROM [forumTopics]
LEFT JOIN forumComments ON forumComments.topicId = forumTopics.id
where forumTopics.memberId = " + memberId + " OR forumComments.memberId = " + memberId;
var x = Businesslogic.Data.GetDataSet(sql, "yourTopicsCount");
return x;
}
public static XPathNodeIterator TopicsWithAuthor(int memberId) {
return Businesslogic.Data.GetDataSet("SELECT * FROM forumTopics where memberid = " + memberId.ToString(), "topic");
}