Umbraco xslt 导航查询 [英] Umbraco xslt navigation query

查看:31
本文介绍了Umbraco xslt 导航查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

用我的 Umbraco xslt 导航宏有点挣扎.我已经让顶级工作了,但现在意识到我需要第二级,并且每个顶级 LI 都有一个独特的类(以及在适当的情况下选定的类).谁能帮我吗?

这是我目前所拥有的:

<xsl:template match="/"><ul id="section_navigation"><xsl:for-each select="umbraco.library:GetXmlNodeById('1137')/ancestor-or-self::* [@level=$level]/* [@isDoc and string(umbracoNaviHide) != '1']"><li><a href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="@nodeName"/></a><xsl:if test="count(./child::*[@isDoc and string(umbracoNaviHide) != '1']) &gt; 0"><div class="sub"><ul><xsl:for-each select="./child::*[@isDoc and string(umbracoNaviHide) != '1']"><li><a href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="@nodeName"/></a></xsl:for-each>

</xsl:if></xsl:for-each></xsl:模板>

这是我正在寻找的结果:

    <li class="pal"><a href="/Pal">Pal</a></li><li class="memo"><a href="/memo">Memo</a><div class="sub"><ul><li><a href="/memo/latest">最新</a></li><li><a href="/memo/history">历史</a></li>>

<li class="questions"><a href="/questions">问题</a></li><li class="office"><a href="/office">Office</a></li><li class="mail"><a href="/mail">Mail</a><div class="sub"><ul><li><a href="/mail/mailbox">MailBox</a></li><li><a href="/mail/new-message">新邮件</></li>

<li class="jobs"><a href="/jobs">jobs</a><div class="sub"><ul><li><a href="/jobs/all">All</a></li><li><a href="/jobs/magazine">杂志</a></li>

不确定 div class="sub" 中的子部分是否正确.也许如果我将选定的类添加到父 LI 中,虽然它可能会起作用.

我想到了 LI 类,我可以使用页面名称并尝试诸如 <li class="{@Name}"> 之类的东西,但没有成功.任何想法也将不胜感激.

如果有更多信息有用,请告诉我.

非常感谢

解决方案

您可能希望尝试以下 Umbraco 包:

http://our.umbraco.org/projects/website-实用程序/cogworks-flexible-navigation

您可以查看 XSLT 以了解它是如何工作的,也可以直接使用它(我认为它会满足您的需求).

就您最初的问题而言,听起来您似乎需要一些有关 Umbraco 本身的参考信息.

最好的地方是 Umbraco wiki

Struggling a bit with my Umbraco xslt navigation macro. I've got the top level working, but now realize I need a second level, and also for each top level LI to have a unique class (and a selected class where appropriate). Can anyone help me out?

This is what I have so far:

<xsl:variable name="level" select="1"/>    
<xsl:template match="/">    
<ul id="section_navigation">
<xsl:for-each select="umbraco.library:GetXmlNodeById('1137')/ancestor-or-self::* [@level=$level]/* [@isDoc and string(umbracoNaviHide) != '1']">
  <li>
    <a href="{umbraco.library:NiceUrl(@id)}">
      <xsl:value-of select="@nodeName"/>
    </a>
    <xsl:if test="count(./child::*[@isDoc and string(umbracoNaviHide) != '1']) &gt; 0">
      <div class="sub">
        <ul>
          <xsl:for-each select="./child::*[@isDoc and string(umbracoNaviHide) != '1']">
            <li>
              <a href="{umbraco.library:NiceUrl(@id)}">
                <xsl:value-of select="@nodeName"/>
              </a>
            </li>
          </xsl:for-each>
        </ul>
      </div>
    </xsl:if>
  </li>
</xsl:for-each>
</ul>    
</xsl:template>

and here's the result I'm looking for:

<ul id="section_navigation">
        <li class="pal"><a href="/Pal">Pal</a></li>
        <li class="memo"><a href="/memo">Memo</a>
            <div class="sub">
                <ul>
                    <li><a href="/memo/latest">Latest</a></li>
                    <li><a href="/memo/history">History</a></li>>
                </ul>
            </div>
        </li>
        <li class="questions"><a href="/questions">Questions</a></li>
        <li class="office"><a href="/office">Office</a></li>
        <li class="mail"><a href="/mail">Mail</a>
            <div class="sub">
                <ul>
                    <li><a href="/mail/mailbox">MailBox</a></li><li><a href="/mail/new-message">New Message</a></li>
                </ul>
            </div>
        </li>
        <li class="jobs"><a href="/jobs">jobs</a>
            <div class="sub">
                <ul>
                    <li><a href="/jobs/all">All</a></li>
                    <li><a href="/jobs/magazine">Magazine</a></li>
                </ul>
            </div>
        </li>
    </ul>

Not sure if the sub-section within div class="sub" is right. Maybe if I add the selected class to the parent LI though it might work.

I thought for the LI class, I could use the page Name and try something like <li class="{@Name}">, but had no success with that. Any ideas there would be appreciated too.

Let me know if any more info would be useful.

Many thanks

解决方案

You may wish to try the following Umbraco package:

http://our.umbraco.org/projects/website-utilities/cogworks-flexible-navigation

You can view the XSLT for it to see how it works or just use it our of the box (I think it will meet your needs).

In terms of your original question, it sounds as if you need some reference information on Umbraco its self.

The best place for that is the Umbraco wiki

这篇关于Umbraco xslt 导航查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
其他开发最新文章
热门教程
热门工具
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆