Drupal 7:使用node_load_mulltiple时的主题化节点
我正在加载 10 个不同内容类型的节点,并且需要为每个节点设置不同的样式。
当前的html输出:
<article id="node-2293" class="node node-postit node-promoted contextual-links-region
node-even clearfix" typeof="sioc:Item foaf:Document" about="/en/number-6-jan-22">
<header class="node-header">
<div class="node-content content"> </div>
<footer class="node-footer">
</article>
问题是node_load_multiple()或node_view_multiple()根据每个节点的nid为每个节点的文章提供一个id。我想将每个节点分配或封装在我自己的 div 和我自己的 id 中,以便我可以为它们每个节点设置样式。
我的模块代码:
if ($nodes = node_load_multiple($customvishalnodestoshow)) {
$build['nodes'] = node_view_multiple($nodes, 'full');
}
我该如何实现这个?
干杯, 维沙尔
I am loading 10 nodes of different content types and I need to style each node differently.
The current html output:
<article id="node-2293" class="node node-postit node-promoted contextual-links-region
node-even clearfix" typeof="sioc:Item foaf:Document" about="/en/number-6-jan-22">
<header class="node-header">
<div class="node-content content"> </div>
<footer class="node-footer">
</article>
The problem is node_load_multiple() or node_view_multiple() are giving each node's article an id as per their nid. I want to assign or encapsulate each node in my own div and my own id so that I can style them each one of them.
My Module code:
if ($nodes = node_load_multiple($customvishalnodestoshow)) {
$build['nodes'] = node_view_multiple($nodes, 'full');
}
How can I implement this ?
Cheers,
Vishal
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您只是尝试以不同的方式为不同的节点类型设置主题,那么主题文件夹中的 node.tpl.php 就是用于此目的的。您可以复制现有的 node.tpl.php 并为每种节点类型创建一个并在其中编写自定义 HTML。
例如,如果您有名为“book”、“story”和“blog”的节点类型,请创建以下模板文件:
If you are just trying to theme different node types differently, thats what node.tpl.php in your theme folder is for. you can copy the existing node.tpl.php and create one for each node type and write custom HTML there.
For example, if you have node types called 'book', 'story' and 'blog', create these template files: