Drupal 7:使用node_load_mulltiple时的主题化节点

发布于 2024-12-28 11:32:28 字数 749 浏览 2 评论 0原文

我正在加载 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

戏剧牡丹亭 2025-01-04 11:32:28

如果您只是尝试以不同的方式为不同的节点类型设置主题,那么主题文件夹中的 node.tpl.php 就是用于此目的的。您可以复制现有的 node.tpl.php 并为每种节点类型创建一个并在其中编写自定义 HTML。

例如,如果您有名为“book”、“story”和“blog”的节点类型,请创建以下模板文件:

  • node--book.tpl.php
  • node--story.tpl.php
  • node--blog.tpl.php

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:

  • node--book.tpl.php
  • node--story.tpl.php
  • node--blog.tpl.php
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文