Sitecore 演示:根本不使用 XSLT 渲染

发布于 2024-11-27 12:37:58 字数 162 浏览 0 评论 0原文

我是 Sitecore 的新手,我们的团队正在使用 Sitecore 构建我们的第一个项目。当我浏览大量教程时,大多数教程都使用 XSLT 渲染。但我想知道使用 XSLT 可以完成的所有操作是否也可以通过子布局完成(例如渲染内容集合)?如果可能的话,我想在这个项目中避免使用 XSLT。

谢谢!

I am new to Sitecore and our team is building our first project using Sitecore. As I look through a lot of the tutorials, most of them use XSLT renderings. But I was wondering whether everything that can be done with XSLT can also be done through a Sublayout (e.g. rendering a collection of content)? If possible, I would like to avoid XSLTs for this project.

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

她比我温柔 2024-12-04 12:37:58

Sitecore 使用三种主要类型的渲染技术。它们一起属于“渲染”总括术语。 XSLT 非常不受欢迎,因为它是它自己的语言。 WebControls 和 Sublayouts 很相似,但处理几乎相同的事情的方法不同。两者都是用 C# 实现的。

  1. XSLT - 使用 XSLT 语言的 XSL 转换文件。这些 WebControl 可以实现有限的功能
  2. - 这些是编译成 DLL 并用作服务器控件的 C# 类。这里可以完成很多功能,但需要注意的是,前端代码是使用 HtmlTextWriter 用 C# 编写的(IMO:“废话!”)
  3. 子布局 - 这些是具有前端的用户控件end ascx 文件和 ascx.cs CodeBehind 将前端与后端逻辑分开。这就像 WebControl,但将设计和逻辑问题分开,以便轻松编写可重用的组件。可以在其中创建任何功能,并且可以仅使用子布局(除了布局之外)构建整个站点。

对于 Sitecore 关于这些技术的官方文档,它们的解释如下
演示文稿组件参考 http://sdn.sitecore.net/" rel="noreferrer">SDN 在选择表示技术部分下。

我的观点:子布局是正确的选择。

There are three main types of rendering technologies used with Sitecore. Together they fall under the "rendering" umbrella term. XSLT is quite unpopular as it is it's own language. WebControls and Sublayouts are similar but different approaches to almost the same thing. Both are implemented in C#.

  1. XSLT - XSL transformation files using the XSLT language. Limited functionality can be implemeneted with these
  2. WebControls - these are C# classes that get compiled into a DLL and used as server controls. Lots of functionality can be done here but the caveat is that front-end code is written in C# using HtmlTextWriters (IMO: "blah!")
  3. Sublayouts - These are User Controls that have both a front-end ascx file and ascx.cs CodeBehind to separate the front-end end from the back-end logic. This is just like a WebControl but separates the design and logic concerns to make it easy to write re-usable components. Any functionality can be created in these and its possible to build entire sites with just sublayouts (in addition to layouts).

For Sitecore's official documentation on these technologies, they're explained in
the Presentation Component Reference on the SDN under the section Choosing Presentation Technology.

My opinion: sublayouts are the way to go.

木格 2024-12-04 12:37:58

XSLT 中可以完成的所有操作都可以在 SubLayout(只是 ASCX 或 WebControl)中完成。事实上,有些事情在 XSLT 中很难做到,而实际上在 SubLayout 中做得更好。

做XSLT的主要原因主要是为了方便输出。输出一些 HTML 和显示字段要容易得多,但这绝不是必需的。

我已经使用 Sitecore 一年了,在不得不使用 XSLT 方面我还没有发现任何问题。

Everything that can be done in XSLT can be done in a SubLayout (which is just an ASCX or WebControl). There are in fact some things that are difficult to do in XSLT, and in fact are done better in a SubLayout.

The main reason to do XSLT is mostly for easy output. It's alot easier to output some HTML and display fields, but it is by no means required.

I've been using Sitecore for a year now, and I haven't found any problems where I had to use XSLT.

你是年少的欢喜 2024-12-04 12:37:58

我建议避免使用 XSLT。它们看起来很容易使用,但是当涉及到重构时,它们就变得根本无法使用。
您无法使用 Resharper 之类的工具来重构 XSLT,并且每次需要输出值时都无法使用域模型来代替字段名称。

如果您需要向 XSLT 添加一些新功能 - 很可能没有 xsl 扩展就无法做到这一点。最终您将得到许多 CustomXslHelper 类,这些类允许在 XSLT 中使用 Sitecore API 和基本 .NET 操作。

I'd suggest to avoid using XSLT. They seem pretty easy to use, but when it comes to refactoring - they become unusable at all.
You can't use tools like Resharper to refactor XSLT's, and there is no way to use Domain Model instead of fields names each time you need to output values.

If you need to add some new functionality to XSLT - there is a big chance it's impossible to do without xsl extensions. And you will end up with lots of CustomXslHelper classes that allow use of Sitecore API and basic .NET operations in XSLT.

明明#如月 2024-12-04 12:37:58

我认为无论如何使用 xslt 都会比使用子布局方法更早地遇到问题。我们开始使用 XSLT 开发网站,但几个月后开始使用子布局。我现在无法想象一个基于 XSLT 构建的新 Web 应用程序。当有很多 xslt 本身无法完成的事情可以在子布局方法中轻松完成时,子布局是可行的方法。最重要的是,您将能够享受 Visual Studio 的好处,并且它的功能更多地使用子布局。

I think that you'll bump into problems using xslt far earlier then by using the sublayout approach anyway. We started developing websites using XSLT but after a few months started using sublayouts instead. I can't imagine a new web app build on XSLT now. Sublayouts are the way to go, when there are alot of things xslt can't do on it's own which can be done in the sublayout approach easily. On top of that you'll be able to have the benefits of visual studio and it's functions alot more using sublayouts.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文