您的位置: 首页 >日志>前端技术>详细内容

前端技术

取得第N级父节点ID

来源:本站原创 发布时间:2012-10-31 15:21:51 浏览次数: 【字体:

      在这个月的项目中都需要利用节点来制作子站,既然是子站,自然有他独自的导航和栏目以及最新信息等,而这些都需要获得该子站的根节点ID,但是子站的根节点在整个节点级别中又不确定,有时候新建第1级别节点为子站的根节点,有时候可能是第N级别为子站的根节点。而且改子站的子节点等都得获取到子站根节点ID。这样才能无论保持子站的导航等信息一致。经过查找没有发现能获取这样ID的标签,于是我就研究一下数据库节点之间的关系,然后重新制作了一个标签,暂时命名为:取得第N级父节点ID。

取得第N级父节点ID

  1. xml version="1.0" encoding="utf-8"?>
  2. <root>
  3.   <LabelType>栏目类 LabelType>
  4.   <LabelIntro>
  5.    LabelIntro>
  6.   <OutType>sin OutType>
  7.   <LabelDataType>sql_sysquery LabelDataType>
  8.   <EnabelAjax>False EnabelAjax>
  9.   <attributes>
  10.     <name>nodeid name>
  11.     <datatype>string datatype>
  12.     <default> default>
  13.     <intro>当前节点ID intro>
  14.    attributes>
  15.   <attributes>
  16.     <name>depth name>
  17.     <datatype>string datatype>
  18.     <default>0 default>
  19.     <intro>节点深度 intro>
  20.    attributes>
  21.   <LabelSqlString>SELECT parentID, NodeID,Depth  FROM PE_Nodes WHERE NodeID=@nodeid LabelSqlString>
  22.   <LabelTemplate><?xml version="1.0" encoding="utf-8"?></span></li> <li class="alt" style="border-width: initial; border-color: initial; "><span class="cdata"><xsl:transform version="1.0" xmlns:xsl="" xmlns:pe="labelproc" exclude-result-prefixes="pe"></span></li> <li style="border-width: initial; border-color: initial; "><span class="cdata"><xsl:output method="html" /></span></li> <li class="alt" style="border-width: initial; border-color: initial; "><span class="cdata"><xsl:param name="nodeid"/></span></li> <li style="border-width: initial; border-color: initial; "><span class="cdata"><xsl:param name="depth"/></span></li> <li class="alt" style="border-width: initial; border-color: initial; "><span class="cdata"><xsl:template match="/NewDataSet"></span></li> <li style="border-width: initial; border-color: initial; "><span class="cdata"><xsl:choose></span></li> <li class="alt" style="border-width: initial; border-color: initial; "><span class="cdata"><xsl:when test="Table/Depth= $depth "></span></li> <li style="border-width: initial; border-color: initial; "><span class="cdata"><xsl:value-of select="$nodeid"/></span></li> <li class="alt" style="border-width: initial; border-color: initial; "><span class="cdata"></xsl:when></span></li> <li style="border-width: initial; border-color: initial; "><span class="cdata"><xsl:otherwise></span></li> <li class="alt" style="border-width: initial; border-color: initial; "> </li> <li style="border-width: initial; border-color: initial; "><span class="cdata">{PE.Label id="取得第N级父节点ID" nodeid="<xsl:value-of select="Table/parentID"/>" depth="<xsl:value-of select="$depth"/>" /}</span></li> <li class="alt" style="border-width: initial; border-color: initial; "> </li> <li style="border-width: initial; border-color: initial; "><span class="cdata"></xsl:otherwise></span></li> <li class="alt" style="border-width: initial; border-color: initial; "><span class="cdata"></xsl:choose></span></li> <li style="border-width: initial; border-color: initial; "><span class="cdata"></xsl:template></span></li> <li class="alt" style="border-width: initial; border-color: initial; "><span class="cdata"></xsl:transform> LabelTemplate>
  23. root>

      调用方式:{PE.Label id="取得第N级父节点ID" nodeid=" $currentId"/>" depth="1"/} ;这样就能根据当前ID调用到第2级的父节点ID或者第2级本身节点ID。 

       既然可以就可以应用到子站导航等方面,例如如下:

  1. xml version="1.0" encoding="utf-8"?>
  2. <root>
  3.   <LabelType>静态类 LabelType>
  4.   <LabelIntro>
  5.    LabelIntro>
  6.   <OutType>txt OutType>
  7.   <LabelDataType>static LabelDataType>
  8.   <EnabelAjax>False EnabelAjax>
  9.   <LabelTemplate><!-- header S--></span></li> <li style="border-width: initial; border-color: initial; "><span class="cdata">    <div id="header"></span></li> <li class="alt" style="border-width: initial; border-color: initial; "><span class="cdata">        <div class="banner">{PE.Label id="自设内容" nodeid="{PE.Label id="取得第N级父节点ID" nodeid="<xsl:value-of select="$currentId"/>" depth="1"/}" num="1" /} </div></span></li> <li style="border-width: initial; border-color: initial; "><span class="cdata">        <div id="nav"></span></li> <li class="alt" style="border-width: initial; border-color: initial; "><span class="cdata">            <a class="home" href="{PE.SiteConfig.SitePath /}">返回首页</a></span></li> <li style="border-width: initial; border-color: initial; "><span class="cdata">            {PE.Label id="多级导航菜单" nodeid="{PE.Label id="取得第N级父节点ID" nodeid="<xsl:value-of select="$currentId"/>" depth="1"/}" indexName="网站首页" depth="1" effect="slide" splitchar="1" currentId="<xsl:value-of select="$currentId"/>"/}</span></li> <li class="alt" style="border-width: initial; border-color: initial; "><span class="cdata">        </div></span></li> <li style="border-width: initial; border-color: initial; "><span class="cdata">        <div class="searchBar"></span></li> <li class="alt" style="border-width: initial; border-color: initial; "><span class="cdata">            <div class="ann"><span class="date">今天是:<script type="text/javascript" src="{PE.SiteConfig.SkinPath/}js/show_date.js"></script></span><iframe id="weather" name="weather_inc" src="" width="330" height="28" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" allowTransparency="true"></iframe></div></span></li> <li style="border-width: initial; border-color: initial; "><span class="cdata">        </div></span></li> <li class="alt" style="border-width: initial; border-color: initial; "><span class="cdata">    </div></span></li> <li style="border-width: initial; border-color: initial; "><span class="cdata"><!-- header E --></span></li> <li class="alt" style="border-width: initial; border-color: initial; "><span class="cdata"> LabelTemplate>
  10.   <attributes>
  11.     <name>currentId name>
  12.     <datatype>supersql datatype>
  13.     <default>@ RequestInt_id default>
  14.     <intro>当前节点ID intro>
  15.    attributes>
  16. root>
×

用户登录