Drupal 7 主题化单独页面
我正在启动一个 Drupal 7 站点,并注意到几乎每个页面都需要单独的布局。
为了设计单个节点的样式,我是否只需命名一个模板 mode-NID-page.tpl.php 还是还有更多内容?
我想我还需要添加画廊小部件等。但我认为这是一个单独的问题。但这是否涉及在上述模板中显示字段?
I'm starting a Drupal 7 site and have noticed that almost every page will require a separate layout.
in order to style an individual node do i just name a template mode-NID-page.tpl.php or is there more to it?
I think i will also need to add gallery widgets, etc.. but i think that's a separate matter. But would this involve displaying fields in the above template?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先:我认为根据 NID 来设置页面主题不是一个好主意。
除此之外,这里有两种可能性如何实现这样的事情:
主题化普通节点模板,但在其中包含一些逻辑。例如,您可以包含基于 NID 的特定模板文件。当然,这不是一个干净的分离,因为这样的代码不应该进入模板。为了更清晰的分离,您可以将自定义字段附加到包含用于主题化的模板文件的页面。
对
由于您想为不同的 NID 创建单独的样式,我假设这些样式的数量不会太大。在这种情况下,您可以创建单独的内容类型。然后,每个 NID 都应该转换为该内容类型的节点,当然每个内容类型都可以有自己的主题模板。
第二种方法的缺点是,如果您有很多设置需要转移到内容类型(例如权限),则可能会涉及一些工作。但话又说回来,新页面也将是节点,因此大多数事情应该像以前一样开箱即用。
First off: I don't think it's a good idea to theme pages based on their NID.
That aside, here are two possibilities how you can achieve something like this:
Theme the normal node template, but include some logic there. You could for example include specific template files based on the NID. Not a clean separation of course, as such code should not go into templates. For a cleaner separation you could attach a custom field to the pages that holds the template file used for themeing.
As you want to create individual styles for different NIDs I assume that the number of those is not exorbitantly large. In that case, you could create separate content types. Each of the NIDs should then be converted into a node of that content type and of course each content type can have its own theme template then.
Downside of the second approach is that there might be some work involved if you have a lot of settings that would need to be transferred to the content types (e.g., permissions). But then again, the new pages will be nodes too, so most things should just work out of the box as they did before.