English 中文(简体)
XSLT (Umbraco)
原标题:XSLT (Umbraco) if certain doc type
  • 时间:2011-11-09 14:20:18
  •  标签:
  • xslt
  • umbraco

我在乌布拉科宏观中产生了一个菜单:

<xsl:for-each select="$currentPage/* [@isDoc and string(umbracoNaviHide) !=  1  and @level &lt;= $maxLevel and (umbraco.library:IsProtected(@id, @path) = false() or umbraco.library:HasAccess(@id, @path) = true())] ">
  <li>
      <a href="{umbraco.library:NiceUrl(@id)}">
        <xsl:value-of select="@nodeName"/>
      </a>     
  </li>
</xsl:for-each>

在座各位中,我想说的是,只接受某种手法,并产生各自的利/标签,并且用手法中这种手法插入一个小数。 我只能认为:

      <xsl:if test="$currentPage/Redirect">
        <li>
           <a href="{$urlRedirect)}">
              <xsl:value-of select="@nodeName"/>
           </a>
        </li>
      </xsl:if>

<代码>Redirect为异构体,$urlRedirect为时段。

与我一样,这是我第一天学习的XSLT。

UPDATE: Heres the complete code so you can see it in context:

<xsl:template match="/">
<!-- The fun starts here -->  
<!-- update this variable on how deep your navigation should be -->
<xsl:variable name="maxLevel" select="5"/>
<xsl:variable name="minLevel" select="4"/>

<xsl:choose>
  <xsl:when test="$currentPage/* [@isDoc and string(umbracoNaviHide) !=  1  and @level &lt;= $maxLevel and (umbraco.library:IsProtected(@id, @path) = false() or umbraco.library:HasAccess(@id, @path) = true())] ">
    <ul>
    <xsl:for-each select="$currentPage/* [@isDoc and string(umbracoNaviHide) !=  1  and @level &lt;= $maxLevel and (umbraco.library:IsProtected(@id, @path) = false() or 

umbraco.library:HasAccess(@id, @path) = true())] ">

<!-- Here is where I want my if/else logic -->

      <li>
        <a href="{umbraco.library:NiceUrl(@id)}">
          <xsl:value-of select="@nodeName"/>
        </a>
      </li>

    </xsl:for-each>
    </ul>
  </xsl:when>
  <xsl:otherwise>
    <ul>

      <xsl:for-each select="$currentPage/../* [@level &gt; 3 and @isDoc and string(umbracoNaviHide) !=  1  and (umbraco.library:IsProtected(@id, @path) = false() or umbraco.library:HasAccess(@id, @path) = true())] ">
      <li>
        <a href="{umbraco.library:NiceUrl(@id)}">
          <xsl:value-of select="@nodeName"/>
        </a>
      </li>
    </xsl:for-each>
    </ul>
  </xsl:otherwise>
</xsl:choose>

</xsl:template>
最佳回答

你可以这样做:

    <xsl:template match="/">
<!-- The fun starts here -->  
<!-- update this variable on how deep your navigation should be -->
<xsl:variable name="maxLevel" select="5"/>
<xsl:variable name="minLevel" select="4"/>

<xsl:choose>
  <xsl:when test="$currentPage/* [@isDoc and string(umbracoNaviHide) !=  1  and @level &lt;= $maxLevel and (umbraco.library:IsProtected(@id, @path) = false() or umbraco.library:HasAccess(@id, @path) = true())] ">
    <ul>
    <xsl:apply-templates select="$currentPage/* [@isDoc and string(umbracoNaviHide) !=  1  and @level &lt;= $maxLevel and (umbraco.library:IsProtected(@id, @path) = false() or umbraco.library:HasAccess(@id, @path) = true())]"  />
    </ul>
  </xsl:when>
  <xsl:otherwise>
    <ul>

      <xsl:for-each select="$currentPage/../* [@level &gt; 3 and @isDoc and string(umbracoNaviHide) !=  1  and (umbraco.library:IsProtected(@id, @path) = false() or umbraco.library:HasAccess(@id, @path) = true())] ">
      <li>
        <a href="{umbraco.library:NiceUrl(@id)}">
          <xsl:value-of select="@nodeName"/>
        </a>
      </li>
    </xsl:for-each>
    </ul>
  </xsl:otherwise>
</xsl:choose>

</xsl:template>

<xsl:template match="*">
     <li>
         <a href="{umbraco.library:NiceUrl(@id)}">
                <xsl:value-of select="@nodeName"/>
         </a>     
      </li>
</xsl:template>
<xsl:template match="Redirect">
    <li>
        <a href="{urlRedirect}">
            <xsl:value-of select="@nodeName"/>
        </a>
    </li>
</xsl:template>
问题回答

暂无回答




相关问题
When test hanging in an infinite loop

I m tokenising a string with XSLT 1.0 and trying to prevent empty strings from being recognised as tokens. Here s the entire function, based on XSLT Cookbook: <xsl:template name="tokenize"> ...

quick xslt for-each question

Let s say I have an XML document that has this: <keywords> <keyword>test</keyword> <keyword>test2</keyword> <keyword>test3</keyword> <keyword>test4</...

XSLT Transform XML with Namespaces

I m trying to transform some XML into HTML using XSLT. Problem: I can t get it to work. Can someone tell me what I m doing wrong? XML: <ArrayOfBrokerage xmlns:i="http://www.w3.org/2001/...

XSLT output to HTML

In my XSLT file, I have the following: <input type="button" value= <xsl:value-of select="name">> It s an error as it violates XML rule. What I actually want is having a value from an ...

Mangling IDs and References to IDs in XML

I m trying to compose xml elements into each other, and the problem I am having is when there s the same IDs. Basically what I need to do is mangle all the IDs in an xml file, as well as the ...

Sharepoint 2007 Data view Webpart custom parameters

I m sort of new to the custom parameters that can be setup on a DataView Webpart. There are 6 options: - None - Control - Cookie - Form - QueryString - Server Variable I think that None, Cookie and ...

热门标签