全站导航

当前位置:首页/ 网站建设/ 动易专题>正文

动易专题

【重磅】利用存储过程写通用信息列表标签

人气指数: 次  发布时间:2020年04月21日




查询语句:

<?xml version="1.0" encoding="utf-8"?>

<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:pe="labelproc" exclude-result-prefixes="pe">

<xsl:output method="xml" omit-xml-declaration="yes" />

<xsl:param name="nodeId" />

<xsl:param name="modelId" />

<xsl:param name="listOrderType" />

<xsl:template match="/">

<xsl:variable name="_nodes">

<xsl:if test="$nodeId > 0">

<xsl:value-of select="pe:GetNodesArrChildId($nodeId)"/>

</xsl:if>

</xsl:variable>

<xsl:variable name="_table">PE_CommonModel CM 

<xsl:if test="$modelId > 0">

<xsl:value-of select="pe:GetSqlSnippet($modelId)"/>   

</xsl:if>

</xsl:variable>

<xsl:variable name="_listOrderType">

  <xsl:choose>

    <xsl:when test="$listOrderType = 0">CM.UpdateTime desc</xsl:when>

    <xsl:when test="$listOrderType = 1">CM.Hits desc</xsl:when>

    <xsl:when test="$listOrderType = 2">CM.EliteLevel desc,CM.Updatetime desc</xsl:when>

    <xsl:when test="$listOrderType = 3">CM.UpdateTime desc</xsl:when>

    <xsl:when test="$listOrderType = 4">CM.UpdateTime asc</xsl:when>

    <xsl:when test="$listOrderType = 5">CM.Hits desc</xsl:when>

    <xsl:when test="$listOrderType = 6">CM.Hits asc</xsl:when>

                <xsl:otherwise>CM.UpdateTime DESC,CM.GeneralID DESC</xsl:otherwise>

</xsl:choose>

</xsl:variable>

<xsl:variable name="_commonFilter">

 CM.Status = 99 

<xsl:if test="$nodeId > 0">

 AND CM.NodeID in (<xsl:value-of select="$_nodes"/>)  

</xsl:if>

</xsl:variable>

<xsl:variable name="_filterQuery">

<xsl:value-of select="$_commonFilter"/>

<!--<xsl:if test="$area!='' and $area != 'All'">

 AND UT.area = ''<xsl:value-of select="$area"/>''  

</xsl:if>

<xsl:if test="$type1!='' and $type1 != 'All'">

 AND UT.type = ''<xsl:value-of select="$type1"/>''  

</xsl:if>

<xsl:if test="$type2!='' and $type2 != 'All'">

 AND UT.type2 = ''<xsl:value-of select="$type2"/>''  

</xsl:if>

<xsl:if test="$banben!='' and $banben != 'All'">

 AND UT.banben = ''<xsl:value-of select="$banben"/>''  

</xsl:if>-->

</xsl:variable>

<xsl:variable name="_filterCount">

<xsl:value-of select="$_commonFilter"/>

<!--<xsl:if test="$area!='' and $area != 'All'">

 AND UT.area = '<xsl:value-of select="$area"/>'  

</xsl:if>

<xsl:if test="$type1!='' and $type1 != 'All'">

 AND UT.type = '<xsl:value-of select="$type1"/>'  

</xsl:if>

<xsl:if test="$type2!='' and $type2 != 'All'">

 AND UT.type2 = '<xsl:value-of select="$type2"/>'  

</xsl:if>

<xsl:if test="$banben!='' and $banben != 'All'">

 AND UT.banben = '<xsl:value-of select="$banben"/>'  

</xsl:if>-->

</xsl:variable>

<root>

<sql>

EXEC [dbo].[PR_Common_PagingLarge]  '<xsl:value-of select="$_table"/>', 'CM.GeneralID', '*', @pagesize, @startrow, '<xsl:value-of select="$_filterQuery"/>','','<xsl:value-of select="$_listOrderType"/>' 

</sql>

<countsql>

select count(CM.GeneralID) from <xsl:value-of select="$_table"/> where <xsl:value-of select="$_filterCount"/>

</countsql>

</root>

</xsl:template>

</xsl:transform>


标签内容:

<?xml version="1.0" encoding="utf-8"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:pe="labelproc" exclude-result-prefixes="pe">

<xsl:param name="nodeId" />

<xsl:param name="modelId" />

<xsl:param name="listOrderType" />

<xsl:param name="titleLength" />

<xsl:output method="html" />

<xsl:template match="NewDataSet">

        <xsl:choose>

            <xsl:when test="Table">

                <xsl:for-each select="Table">

<li>

<a href="{pe:GetInfoPath(ItemID)}" title="{Title}" target="_blank">

<xsl:value-of select="pe:CutText(Title,$titleLength,'…')"/>

</a>

</li>

                </xsl:for-each>

            </xsl:when>

            <xsl:otherwise>

                <span class="missing_data">还没有任何内容!</span>

            </xsl:otherwise>

        </xsl:choose>

</xsl:template>

</xsl:stylesheet>


调用方法:

{PE.Label id="M_通用信息列表" page="true" pagesize="20" titleLength="80" nodeId="1775" listOrderType="1" modelId="0" cachetime="600" cacheid="M_通用信息列表1775-0"/}


返回首页