开发者

How does umbraco mix XSLT with C# code

Take a look at this code:

<ul>  
 <xsl:for-each select="$currentPage/node">  
 <li><a>
       <xsl:attribute name="href">
          <xsl:value-of select="umbraco.library:NiceUrl(current()/@id)"/>
       </xsl:attribute> 
       <xsl:value-of select="current()/@nodeN开发者_运维百科ame"/>    
     </a>  
 </li>  
 </xsl:for-each>
</ul>

As you can see there are umbraco commands within the xslt. How exactly is this done? How can I put my own C# commands in my xslt?


Create a class with public static methods. Then register your assembly in the XsltExtensions.config file in the config directory.

There is example configuration in the file.


There are a number of approaches for injecting some custom logic. Check it out - http://msdn.microsoft.com/en-us/magazine/cc302079.aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜