使用 Smarty 学习 Drupal 的案例
我正在重新开始并重新学习 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
诚然,我自己没有使用过 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.
根据过去的经验,我同意,从长远来看,在尝试使用 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.
好吧,我必须不同意。 Smarty 是一种彻底分离表示层的绝佳方法:
我想你会发现,有过 Smarty 经验的开发人员通常也会对它有很大的忠诚度。最新的 3.x 版本非常棒。
Well, I have to disagree. Smarty is a fantastic way to make a clean separation of the presentation layer:
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.