Drupal 6:Drupal Themer 为不同类型的内容类型提供相同的候选名称
我是一个 drupal 新手...
我有不同类型的内容,如新闻、活动等,它们的内容是不同的。新闻详细信息页面有标题-内容文本-日期。但活动详细信息页面有标题-日期-内容文本-位置-演讲者等。所以我需要针对这些不同类型的不同布局页面。因此,我启用了 Drupal Themer 来获取候选名称。对于事件页面,它给了我 page-node.tpl.php ,它也为新闻页面提供了相同的信息:(我如何分离这些页面?我期望像 page-event- node.tpl ,但没有...:/ Drupal Themer 还为事件页面提供了唯一的候选名称,例如 page-node-18.tpl.php 但这并不意味着任何事情,因为我可以不通过此节点名称创建所有事件的总体布局:(
感谢帮助很大!!非常感谢!!!
I'm a drupal newbie...
I have different type of contents like News, Events, etc. and their content is different. News detail page has title-content text-date. but Events detail page has title-date-content text-location-speaker-etc. So I need different layout page for these different types. So, I enabled Drupal Themer to get a candidate name. for events page, it gave me page-node.tpl.php and it gives same for News page as well :( how can I separate these pages? I expected sth like page-event-node.tpl , but no... :/ Drupal Themer also give unique candidate name for event page like page-node-18.tpl.php but it doesnt mean anything since I can not create a general layout for all events by this node name. :(
Appreciate helps so much!! Thanks a lot!!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
虽然按照 Monkeyninja (+1) 建议使用不同的 node.tpl.php 文件是“正常”方式,但您可以通过自己根据节点类型添加页面模板建议来添加所需的功能,在
preprocess_page
function 在自定义模块/主题中:有了这个,您应该能够添加例如“page-type-event.tpl.php”文件,该文件应用于所有事件节点页面。
(注意:添加后,您需要触发主题注册表的重建函数使其被系统识别)
While using different node.tpl.php files as suggested by monkeyninja (+1) would be the 'normal' way, you could add the functionality you want by adding page template suggestions based on node type yourself, in a
preprocess_page
function within a custom module/theme:With this in place, you should be able to add e.g. a 'page-type-event.tpl.php' file, which should be used for all event node pages.
(NOTE: You'll need to trigger a rebuild of the theme registry after adding that function to get it recognized by the system)
我不熟悉 Drupal Themer,但稍微不同的方法是使用节点模板来设计内容并使用类似优秀的 上下文模块(可能还有面板模块)来更改布局页面上的任何附加信息(例如块)。
要使用节点模板对不同的内容类型进行主题化,只需以node-content_type.tpl.php 形式基于node.tpl.php 创建模板。因此,您将拥有一个名为 node-events.tpl.php 的事件节点模板。
然后,您可以使用上下文模块定义上下文,该模块在显示事件内容类型的页面时做出反应,并选择要显示的区域/块。
I'm not familiar with Drupal Themer, but a slightly different approach would be to work with the node templates to style the content and use something like the excellent Context module (and possibly Panels module) to change the layout of any additional information on the page (eg the blocks).
To theme the different content types using node templates, just create templates based on node.tpl.php in the form node-content_type.tpl.php. So you'd have a template for your events nodes called node-events.tpl.php.
You could then define a context using the Context module that reacted when a page of the events content type was displayed and select which regions/blocks you wanted displayed.