简体   繁体   English

用Smarty学习Drupal的案例

[英]A Case for Learning Drupal with Smarty

I am starting over and relearning Drupal, hopefully unlearning some bad habits. 我从头开始并重新学习Drupal,希望能学到一些不良习惯。 I'm reading Drupal 6 Themes by Ric Shreves and he briefly covers different theming engines Drupal can use, one of which being Smarty. 我正在阅读Ric Shreves的Drupal 6 Themes,他简要介绍了Drupal可以使用的不同主题引擎,其中之一就是Smarty。

One bad a habit I started with is sometimes putting queries or other complex logic in tpl files. 我开始的一个坏习惯是有时将查询或其他复杂的逻辑放在tpl文件中。 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. 在我对Smarty的短暂体验中,我记得它涉及到格式化和简单的循环构造,因此您必须找到预处理功能。 If I was forced to use Smarty when I first started with Drupal, I probably wouldn't be in the state I am now. 如果我刚开始使用Drupal时被迫使用Smarty,则可能不会处于现在的状态。

Finally a question. 最后一个问题。 Is there a case to be made for people picking up Drupal for the first time to use Smarty? 是否有必要让人们首次使用Drupal来使用Smarty?

Admittedly, I haven't used Smarty myself, but I wouldn't recommend it. 诚然,我自己还没有使用Smarty,但我不推荐使用。 The vast majority of Drupal documentation, books, blog posts, etc are based on PHPTemplate. Drupal的文档,书籍,博客文章等绝大多数都基于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. 如果您需要帮助,您可能会求助的大多数Drupal开发人员不会了解Smarty,或者至少不会像了解PHPTemplate那样了解Smarty。

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. 相反,我认为您最好深入学习并尝试通过学习首选的处事方式来解决原始问题。

I agree from past experience, it will be easier in the long term to just learn PHP fundamentals before trying work with drupal. 我从过去的经验中得出结论,从长远来看,在尝试使用drupal之前学习PHP基础知识会更加容易。 Everything will make more sense if you have a good PHP base. 如果您有良好的PHP基础,那么一切都会更有意义。 Especially when it comes to the CMS. 特别是在CMS方面。

Well, I have to disagree. 好吧,我不同意。 Smarty is a fantastic way to make a clean separation of the presentation layer: Smarty是一种完美分离表示层的绝妙方法:

  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). 您的表示层中没有php(对于更大的解决方案和安全性很重要)。
  3. Smarty provides many "presentation specific" functions to make design simpler Smarty提供了许多“特定于演示文稿”的功能,以简化设计
  4. Smarty's plugin architecture allows very advanced functionality when you need it. Smarty的插件体系结构可在您需要时提供非常高级的功能。
  5. Smarty is well supported and documentation is easy to understand for the front-end folks. Smarty得到了很好的支持,并且文档对于前端人员来说很容易理解。

I think you will find that developers who have experience with Smarty will generally have a lot of loyalty too it. 我认为您会发现,拥有Smarty经验的开发人员通常也会有很多忠诚度。 The newest 3.x versions are fantastic. 最新的3.x版本很棒。

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

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