使用 Smarty 学习 Drupal 的案例

发布于 2024-10-16 11:27:12 字数 363 浏览 3 评论 0原文

我正在重新开始并重新学习 Drupal,希望能改掉一些坏习惯。我正在阅读 Ric Shreves 撰写的 Drupal 6 Themes,他简要介绍了 Drupal 可以使用的不同主题引擎,其中之一是 Smarty。

我开始养成的一个坏习惯是有时将查询或其他复杂逻辑放入 tpl 文件中。为了获得您想要的东西,通常很难跟踪预处理器或模块的链。另外,坦率地说,当你在截止日期前时,它就会起作用。

在我使用 Smarty 的短暂经验中,我记得它归结为格式化和简单的循环结构,因此您必须找到预处理函数。如果我刚开始使用 Drupal 时被迫使用 Smarty,我可能不会是现在的状态。

最后一个问题。对于第一次使用 Drupal 的人来说,是否有理由使用 Smarty?

I am starting over and relearning Drupal, hopefully unlearning some bad habits. I'm reading Drupal 6 Themes by Ric Shreves and he briefly covers different theming engines Drupal can use, one of which being Smarty.

One bad a habit I started with is sometimes putting queries or other complex logic in tpl files. It was often difficult to follow the chain up to the preprocessor or module in order to get what you wanted. Also, quite frankly, when you're on a deadline it just works.

In my short experience with Smarty I remember it boiling down to formatting and simple loop constructs, so you had to to find the preprocessing function. If I was forced to use Smarty when I first started with Drupal, I probably wouldn't be in the state I am now.

Finally a question. Is there a case to be made for people picking up Drupal for the first time to use Smarty?

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

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

发布评论

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

评论(3

谈情不如逗狗 2024-10-23 11:27:12

诚然,我自己没有使用过 Smarty,但我不会推荐它。绝大多数 Drupal 文档、书籍、博客文章等都是基于 PHPTemplate。如果您需要帮助,您可能会求助的大多数 Drupal 开发人员不会了解 Smarty,或者至少不会像了解 PHPTemplate 那样了解它。

我认为你只是用一个问题来换取另一个不同的问题。相反,我认为你最好通过学习首选的做事方式来深入研究并尝试解决最初的问题。

Admittedly, I haven't used Smarty myself, but I wouldn't recommend it. The vast majority of Drupal documentation, books, blog posts, etc are based on PHPTemplate. The majority of Drupal developers you might turn to, if you need help, aren't going to know Smarty, or at least won't know it as well as they know PHPTemplate.

I think you'd just be trading one problem for a another, different problem. Instead, I think you'd be better off digging in and trying to solve the original problem by learning the preferred way to do things.

风吹过旳痕迹 2024-10-23 11:27:12

根据过去的经验,我同意,从长远来看,在尝试使用 drupal 之前学习 PHP 基础知识会更容易。如果您有良好的 PHP 基础,一切都会变得更有意义。尤其是当涉及到 CMS 时。

I agree from past experience, it will be easier in the long term to just learn PHP fundamentals before trying work with drupal. Everything will make more sense if you have a good PHP base. Especially when it comes to the CMS.

俯瞰星空 2024-10-23 11:27:12

好吧,我必须不同意。 Smarty 是一种彻底分离表示层的绝佳方法:

  1. 语法干净简单,让前端人员更容易阅读代码。
  2. 表示层中没有 php(对于更大的解决方案和安全性很重要)。
  3. Smarty 提供了许多“特定于演示”的功能,使设计更加简单。Smarty
  4. 的插件架构可在您需要时提供非常高级的功能。
  5. Smarty 得到了很好的支持,并且文档对于前端人员来说很容易理解。

我想你会发现,有过 Smarty 经验的开发人员通常也会对它有很大的忠诚度。最新的 3.x 版本非常棒。

Well, I have to disagree. Smarty is a fantastic way to make a clean separation of the presentation layer:

  1. The syntax is clean and simple and keeps the code easier to read for front-end folks.
  2. No php in your presentation layer (important for larger solutions and security).
  3. Smarty provides many "presentation specific" functions to make design simpler
  4. Smarty's plugin architecture allows very advanced functionality when you need it.
  5. Smarty is well supported and documentation is easy to understand for the front-end folks.

I think you will find that developers who have experience with Smarty will generally have a lot of loyalty too it. The newest 3.x versions are fantastic.

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