Drupal - 完整节点内容而不是预告片
我正在制作一个博客,但我没有丰富的 Drupal 经验(我正在使用 Drupal 6)。
索引页应包含一篇包含完整内容的帖子,以及接下来的 10 篇展示预告片的帖子。我想知道如何显示第一个加载节点的完整内容。
我的头撞在键盘上几个小时,但我无法找到一个简单的解决方案。我尝试查看所有定义的_vars并且所有都充满了预告片,我尝试使用node_view($node->nid)但它似乎进入了无限递归。我在谷歌上搜索了很多,但似乎没有什么能让我满意的。
我想我不需要使用 View 模块,因为我只想在加载节点时将 $teaser = true 更改为 false。
有人有想法吗?
谢谢大家!
I'm making a blog, but I don't have a large experience with Drupal (I'm using Drupal 6).
The index page should have a post with full content and the next 10 posts showing the teaser. I want to know how to show the full content of just the first loaded node.
I'm hitting my head against the keyboard for hours, but I can't get a simple solution for it. I've tried to see all defined_vars and all are filled with the teaser, I've tried to use node_view($node->nid) but it seems to enter in a infinite recursion. I've been searching a lot in Google, but nothing seems to satisfy.
I guess that I don't need to use the View module for it, cause I just wanna change the $teaser = true to false when I get loaded a node.
Someone have an idea for it?
Thank you all!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我建议使用视图模块。当您逐渐熟悉 Drupal 时,熟悉视图也很重要,因为一旦熟悉了,您就会开始发现越来越多的地方可以使用它。
I'd recommend using the Views module for that. As you're getting familiar with Drupal, it's important to get familiar with Views because once you do, you'll start finding more and more places to use it.
就像 Matt V. 所说,使用视图模块...
但更具体地说..
1) 创建一个新视图,其中过滤器节点类型 = blog,节点已发布 = yes
2) 创建一个“页面显示”(视图 UI 的左侧,选择页面 -> 添加显示)
3)页面显示将“每页项目数”设置为1,将行样式设置为节点,并选择完整节点。然后设置博客“索引”页面的 URL
4) 创建“块显示”(视图 UI 左侧,选择块 -> 添加显示)
5) 在块显示上,将“每页项目数”设置为 10,将行样式设置为节点,然后选择预告片。
6) 保存视图,转到 /admin/build/block,并将博客块视图添加到内容区域的底部。在块设置中,(单击“配置”->“仅在下面列出的页面上显示”单选按钮->输入您的博客“索引”URL。boom.views
。
总而言之,您正在使用视图模块来创建具有 2 个显示器的单节点视图。1 个显示器是具有 1 个完整节点的页面,另一个显示器是具有 10 个预告节点的块,
您可能需要修改两个显示器上的排序标准 。块显示上的 offset 字段(在“每页项目”设置下)(因此块不会显示与页面显示的结果相同的结果)
。
http://www.designtotheme.com/tutorials /views-and-offsets-grouping-multiple-displays-one-view
祝你好运!
Like Matt V. said, use the Views module...
but to be more specific..
1) Create a new view with filter node type = blog, node published = yes
2) Create a "page display" (left side of views UI, select page -> add display)
3) on the page display set "items per page" to 1, set row style to node, and select full node. then set the URL of your blog "index" page
4) Create a "block display" (left side of views UI, select block -> add display)
5) on the block display, set "items per page" to 10, set row style to node, and select teaser.
6) save the view, go to /admin/build/block, and add the blog block view to the bottom of your content region. in the block settings, ( click "configure" -> radio button for "show only on pages listed below" -> enter your blog "index" URL.
boom. views.
So in summary you are using the views module to create a single node view, with 2 displays. 1 display is a page with 1 full node, the other display is a block with 10 teaser nodes.
You'll probably want to tinker with the sort criteria on both displays, and the offset field (under "items per page" settings) on the block display (so the block doesn't show the same result that the page is showing).
This dude does something similar:
http://www.designtotheme.com/tutorials/views-and-offsets-grouping-multiple-displays-one-view
good luck!!
Views 非常适合您的问题。如果您使用视图,您可以为所有预告片创建一个视图,然后添加完整节点视图作为视图标题或使用视图主题。视图主题为您提供了灵活性。
如果您想以编程方式完成所有操作,请尝试使用此方法来加载节点。
如果这不起作用尝试
Views is a great fit for your problem. If you use views you can create a view for all the teasers and then add the full node view as the view header or use a view theme. a view theme gives you allot of flexibility.
If you want to do everything programmatically, try this to load the node.
if that doesn't work try