主题“野外采集”在节点页面 Drupal 7 中
Drupal 7“字段集合” - 如果我想主题化具有“字段集合”的节点页面,我该如何分离字段以进行自定义?到目前为止似乎只有 print render($content['field_collection_name']);输出结果。问题是我不知道如何隔离主题字段。
我为此目的创建了一个节点--content_type.tpl.php,但现在被困在水中了。真的很感谢有人为我挽救了这一天。
解决如下:
下面的一些链接确实非常有帮助,所以请看一下,我已经做了这样的事情 - 在我的案例中要渲染的节点上输入 dsm(print_r($variables)); 带有字段集合的 node--content_type.tpl.php
以找出数组和字段需要的值,然后当然是隐藏。
样式部分看起来像这样
Drupal 7 "field collection" - If I want to theme a node page which has a "field collection", how do I go about separating the fields for customization? It seems thus far that only print render($content['field_collection_name']); outputs the result. The problem is that I can't figure out how to isolate the fields for theming.
I've created a node--content_type.tpl.php for this purpose but now stuck dead in the water. Would really appreciate someone saving the day for me.
Solved as follows:
Some of the links from below are really very helpful so do look, though, I've done something like this -
Enter dsm(print_r($variables));
on node to be rendered in my case node--content_type.tpl.php
with field collection to find out the arrays and field values needed, then hide of course.
The styling part then would look something like this
<div>class="class-for-label-here">My Desired Label - <span class="my-field-class-here"><?php print render($content['my_desired_field_here']['#items'][0]['value']); ?></span></div>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
关于同样的事情,这里有一个相当好的对话:
http://drupal.org/node/1155752
主要答案是使用模板字段主题化--your-field-collection-name.tpl.php
之后,您只需要弄清楚如何从数组和/或对象中检索内容即可!
There's a fairly good conversation about this same thing going on here:
http://drupal.org/node/1155752
Main answer is theming with template field--your-field-collection-name.tpl.php
After that you just need to figure out how to retrieve the contents from the arrays and/or objects!
您可以为您的字段创建自定义字段格式化程序,并在内容类型的设置中使用此格式化程序。
字段格式化程序在将 html 输出渲染到节点模板之前提供对 html 输出的完全控制。
您可以使用这个很棒的教程来创建自定义字段格式化程序: http://www.computerminds.co.uk/articles/creating-new-field-formatters-drupal-7
You may create create a custom field formatter for your field and use this formatter in the set-up of your content type.
Field formatter gives total control over the html output before it is rendered into the node template.
You can use this great tutorial to create a custom field formatter : http://www.computerminds.co.uk/articles/creating-new-field-formatters-drupal-7
要获得更正常的基于模板的主题体验,请尝试 http://drupal.org/node/1187990。希望这将进入 Field Collection 2.x。
For a more normal, template based theming experience try the patch in http://drupal.org/node/1187990. Hopefully this will go into Field Collection 2.x.