主题化node-xxx.tpl.php
我是 drupal 主题的新手。 我想做以下事情: 我有一个产品内容类型,我正在操作它的node-product.tpl.php, 产品内容类型具有“嵌入式视频”类型的 CCK 字段(使用位于 http://drupal .org/project/media)。 因为我需要用标签包装“嵌入视频”字段,所以
我想向我的node-product.tpl.php添加一些如下所示的php代码: “打印主题(...)”
我在sites/all/modules/cck/content-module文件中找到以下函数:
“function content_theme() {
$path = drupal_get_path('模块', '内容') .'/主题'; require_once "./$path/theme.inc";
返回数组( '内容字段' =>大批( '模板' => '内容字段', '参数' =>数组('元素'=> NULL), '路径' => $路径, ),” ...
从该代码我假设我的代码应该是: ” 打印主题('content_field', $element) “
几个问题: 1.我走在正确的道路上吗?我应该使用主题功能吗?我正在调用正确的 cck 挂钩主题吗? 2.假设我是正确的,我无法告诉 $element 参数应该是什么,在我的 node-product.tpl.php 上,我有 $node 参数,其中包含大量数据,我如何从$node 参数应该发送到 theme(...) 函数的正确 $element 吗? 3.是否有比浏览模块代码更好的方法来找出每个模块注册的主题挂钩名称以及它们期望获得的参数?
感谢您阅读我的长问题,我们将不胜感激。
i am new to drupal theming.
i want to do the following:
i have a product content type that i am manipulating it's node-product.tpl.php,
the product content-type has a CCK field of type "Embedded Video" (using the Media module found at http://drupal.org/project/media ).
since i need to wrap the "Embedded Video" field with a
tag i want to add to my node-product.tpl.php some php code that looks like these:
"print theme(...)"
i found in sites/all/modules/cck/content-module file the following function:
"function content_theme()
{
$path = drupal_get_path('module', 'content') .'/theme';
require_once "./$path/theme.inc";
return array(
'content_field' => array(
'template' => 'content-field',
'arguments' => array('element' => NULL),
'path' => $path,
)," ...
from that code i assume that i my code should be:
"
print theme('content_field', $element)
"
couple of questions:
1. am i on the right track ? should i use the theme function, am i am calling the right cck hook theme ?
2. assuming that i am correct, i cant tell what is the $element parameter should be, on my node-product.tpl.php i have the $node parameters that has a lot of data in it, how can i get from the $node parameter the correct $element that should be sent to the theme(...) function ?
3. is there a batter way to find out about each module registered theme hooks name and the parameters they expect to get than browsing the module's code ?
thanks for reading my long question, help will be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
CCK 字段在节点对象上有两种格式:
$node->field_[field_name]
$node->field_[field_name]_rendered
渲染的版本是CCK 字段的主题版本,包含所有标记,另一个版本是包含渲染版本和 CCK 存储的其他数据的数组。
您应该能够使用 CCK 在节点对象上注入的数据来执行您想要的操作,而无需使用主题函数。
CCK field is available on the node object in two formats:
$node->field_[field_name]
$node->field_[field_name]_rendered
The rendered version is the themed version of the CCK field, containing all of the markup, the other version is an array containing the rendered version and other data that CCK has stored.
You should be able to do what you want without a theme function using the data that CCK has injected on the node object.
下次只需使用 print_r() 函数即可。 ;-) 例如,在本例中查找 print_r($node),您会看到很多好东西。
Just use print_r() function next time. ;-) For example, in this case look for print_r($node) and you'll see a lot of goodies.