简体   繁体   English

在umbraco的xslt文件中检索文档类型

[英]Retrieving document types in xslt file in umbraco

Very new to Umbraco and .net, have been getting on fairly well putting my first site together. 对于Umbraco和.net来说,这是一个非常新的知识,它在将我的第一个网站整合在一起方面进展顺利。 However, I've hit a bit of a stumbling block where I have set up a document type called Testimonial Article, which I want to retrieve and loop through in the XSLT file. 但是,我遇到了一个绊脚石,在那儿我建立了一个称为“推荐文章”的文档类型,我想在XSLT文件中进行检索并循环浏览。 I have set up a Macro which is linked to this XSLT file, and I've created and published a Testimonial Article - but there is no results seemingly. 我已经建立了一个链接到此XSLT文件的宏,并且创建并发布了推荐文章-但似乎没有结果。

I am assuming I am trying to access the document type incorrectly in the XSLT file? 我假设我试图在XSLT文件中错误地访问文档类型?

In Testimonials.xslt, very basic: 在Testimonials.xslt中,非常基本:

<xsl:param name="currentPage"/>

<xsl:template match="/">
<xsl:for-each select="umbraco.library:GetXmlAll()//node[@nodeTypeAlias = 'TestimonialArticle']" >
    <p>Result</p>
</xsl:for-each>

</xsl:template>

I have created a Testimonial with document type Testimonial Article: 我创建了文档类型为“推荐文章”的推荐:

在此处输入图片说明

And this is my doc type: 这是我的文档类型:

在此处输入图片说明

I believe doing //node is the old way of doing it. 我相信做//node是做这件事的老方法。 I've replaced it with an //* 我已将它替换为//*

Doing //TestimonialArticle should also work as well instead of umbraco.library:GetXmlAll()//*[@nodeTypeAlias = 'TestimonialArticle'] //TestimonialArticle而不是umbraco.library:GetXmlAll()//*[@nodeTypeAlias = 'TestimonialArticle']

You may find this package helpful when creating your xpath: http://our.umbraco.org/projects/developer-tools/umbraco-xpath-evaluator 在创建xpath时,您可能会发现此软件包很有用: http : //our.umbraco.org/projects/developer-tools/umbraco-xpath-evaluator

<xsl:param name="currentPage"/>

<xsl:template match="/">
<xsl:for-each select="umbraco.library:GetXmlAll()//*[@nodeTypeAlias = 'TestimonialArticle']" >
    <p>Result</p>
</xsl:for-each>

</xsl:template>

with XSLT you'd normally start from some "referencePoint" - in Umbraco that is normally the currentPage variable, and then you go from there - (pseudo code): "currentpage - children - where documentType is .." etc 使用XSLT,您通常会从Umbraco中通常是currentPage变量的“ referencePoint”开始,然后再从那里“-”(伪代码):“ currentpage-children-documentType is ..”等

Have a look here: http://our.umbraco.org/wiki/reference/xslt/the-basics 在这里看看: http : //our.umbraco.org/wiki/reference/xslt/the-basics

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM