将日期和作者添加到node.tpl.php
在下面的代码中,我想显示创建日期、作者并链接它们,但没有显示任何内容。我相信我需要做 $node->
而不是那一行,还没有弄清楚确切的代码。或者,如果我需要在 Drupal 6 安装中的“视图”下更改任何内容,该怎么办?提前致谢!
<?php if($node->type == 'blog'): ?>
<div class="blog-page">
<div class="title-post">
<div class="top-image">
<?php print $node->field_image[0]['view'] ?>
</div><!--TOP-IMAGE-->
<p>Posted on <a href="<?php $row['path'] ?>">?php $row['created'] ?></a>, by
<a href="<?php print url('blog/author/'.$row['uid']) ?>"><?php print $row['name'] ?></a></p>
</div>
<div class="content-page">
<?php print $node->content['body']['#value'] ?>
</div>
</div>
<?php else: ?>
<?php print $content ?>
<?php endif ?>
In the code below I'd like to show the created date, author and have them be linked but nothing for they do not show. I believe I need to be doing $node->
rather that row, haven't figured out the exact code. Or what if anything I need to change under Views in my Drupal 6 installation. Thanks in advance!
<?php if($node->type == 'blog'): ?>
<div class="blog-page">
<div class="title-post">
<div class="top-image">
<?php print $node->field_image[0]['view'] ?>
</div><!--TOP-IMAGE-->
<p>Posted on <a href="<?php $row['path'] ?>">?php $row['created'] ?></a>, by
<a href="<?php print url('blog/author/'.$row['uid']) ?>"><?php print $row['name'] ?></a></p>
</div>
<div class="content-page">
<?php print $node->content['body']['#value'] ?>
</div>
</div>
<?php else: ?>
<?php print $content ?>
<?php endif ?>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Drupal 有一个节点对象,其中包含大量相关信息。基本上,如果您需要使用其中的信息,如作者、日期、标题等,您可以通过打印节点对象轻松确定代码。
为了简单起见,可以说它输出了这样的内容:
要在模板中输出这些信息,您可以按以下方式编写。
对于没有子类的字段:
对于有子类的字段:
这有意义吗?当你把它记下来之后,你就可以在编写 drupal 模板时弄清楚任何事情了。
所以,如果你想构造一个 url,你只需将它链接起来:
Drupal has a node object with tons of related information in it. Basically if you ever need to use information from it like author, date, title, etc, you can easily determine the code by printing the node object.
lets say it outputted something like this for simplicity's sake:
To output those bits of information in your template, you'd write in the following way.
for a field with no subclass:
for a field with a subclass:
Does that make sense? after you get that down, you literally can figure out anything when programming drupal templates.
so, if you wanted to construct a url, you'd just chain it up: