取得第N级父节点ID
在这个月的项目中都需要利用节点来制作子站,既然是子站,自然有他独自的导航和栏目以及最新信息等,而这些都需要获得该子站的根节点ID,但是子站的根节点在整个节点级别中又不确定,有时候新建第1级别节点为子站的根节点,有时候可能是第N级别为子站的根节点。而且改子站的子节点等都得获取到子站根节点ID。这样才能无论保持子站的导航等信息一致。经过查找没有发现能获取这样ID的标签,于是我就研究一下数据库节点之间的关系,然后重新制作了一个标签,暂时命名为:取得第N级父节点ID。
取得第N级父节点ID
- xml version="1.0" encoding="utf-8"?>
- <root>
- <LabelType>栏目类 LabelType>
- <LabelIntro>
- LabelIntro>
- <OutType>sin OutType>
- <LabelDataType>sql_sysquery LabelDataType>
- <EnabelAjax>False EnabelAjax>
- <attributes>
- <name>nodeid name>
- <datatype>string datatype>
- <default> default>
- <intro>当前节点ID intro>
- attributes>
- <attributes>
- <name>depth name>
- <datatype>string datatype>
- <default>0 default>
- <intro>节点深度 intro>
- attributes>
- <LabelSqlString>SELECT parentID, NodeID,Depth FROM PE_Nodes WHERE NodeID=@nodeid LabelSqlString>
- <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>
- root>
调用方式:{PE.Label id="取得第N级父节点ID" nodeid=" $currentId"/>" depth="1"/} ;这样就能根据当前ID调用到第2级的父节点ID或者第2级本身节点ID。
既然可以就可以应用到子站导航等方面,例如如下:
- xml version="1.0" encoding="utf-8"?>
- <root>
- <LabelType>静态类 LabelType>
- <LabelIntro>
- LabelIntro>
- <OutType>txt OutType>
- <LabelDataType>static LabelDataType>
- <EnabelAjax>False EnabelAjax>
- <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>
- <attributes>
- <name>currentId name>
- <datatype>supersql datatype>
- <default>@ RequestInt_id default>
- <intro>当前节点ID intro>
- attributes>
- root>
用户登录
还没有账号?
立即注册