jam*_*848 1 php drupal drupal-6
在这里有点生气...... :)
我只是想将内容配置文件内容类型中的CCK字段添加到page-user.tpl.php(我正在创建一个高度主题的用户配置文件页面).
似乎有两种方法,这两种方法都有一个我无法克服的独特缺点:
'$ content profile'方法.
$var = $content_profile->get_variables('profile');
print $var['field_last_name'][0]['safe'];
Run Code Online (Sandbox Code Playgroud)
这很好,除了我似乎无法将当前查看的用户传递到$ content_profile,因此它始终显示登录用户.
'$ content profile load'方法.
$account_id = arg(1);
$account = user_load($account_id);
$user_id = $account->uid;
$var = content_profile_load('profile', $user_id);
print $var->field_first_name[0]['value'];
Run Code Online (Sandbox Code Playgroud)
很好,但是现在我无法访问完整的渲染字段,只能访问普通值(即如果字段有段落则不会显示).
我怎么能同时拥有这两件事?换句话说,如何显示与当前查看的用户相关的字段(1中的"安全"格式)?
我用谷歌搜索和谷歌搜索,我最终绕圈子走了.:(
干杯,詹姆斯
您的内容配置文件加载方法似乎最接近您的要求.
在你的例子中:
$account_id = arg(1);
$account = user_load($account_id);
$user_id = $account->uid;
$var = content_profile_load('profile', $user_id);
print $var->field_first_name[0]['value'];
Run Code Online (Sandbox Code Playgroud)
$ var只是一个节点对象.您可以通过多种方式获取"完整渲染的字段"(假设您的意思是应用了过滤器的字段).
要检查的最重要的事情是您的字段实际上已正确配置.
转到: admin/content/node-type/[node-type]/fields/field_ [field-name]来配置您的字段,并确保在文本处理下您已选择"已过滤的文本".
如果这不能解决问题,请尝试应用此:
content_view_field(content_fields("field_last_name"), $var, FALSE, FALSE)
Run Code Online (Sandbox Code Playgroud)
(更多信息请访问:http://www.trevorsimonton.com/blog/cck-field-render-node-formatter-format-output-print-echo)
代替这个:
print $var->field_first_name[0]['value'];
Run Code Online (Sandbox Code Playgroud)
如果没有任何帮助...试试我在博客上关于这个问题的一些事情:http: //www.trevorsimonton.com/blog/print-filtered-text-body-input-format-文本处理节点模板场-PHP-的Drupal
| 归档时间: |
|
| 查看次数: |
3614 次 |
| 最近记录: |