自定义字段输出 [英] Customize a field output
问题描述
<?php print render($ item); ?>
,但是当我清除缓存,甚至切换主题时,我仍然会收到所有周围的div和标记。如何覆盖Drupal 7中的field.tpl.php?在您的主题的template.php文件中定义此函数,清除缓存。我假设你已经安装了devel模块。
function your-theme_name_field($ variables){
dsm($ variables ['items'] [0] '#markup']);
return;
}
您将能够访问您要查找的值。
I have a field named "field_enroll_link." I want to remove all the surrounding divs and just print the field content (it will go into the href of an anchor tag). I created the files "field--field_enroll_link-course.tpl.php" and "field--field-enroll-link-course.tpl.php," and put it into my template folder. It just contained <?php print render($item); ?>
, but when I cleared the cached and even switched the themes, I'm still getting all the surrounding divs and markups. How do I override the field.tpl.php in Drupal 7?
In your theme's template.php file define this function and clear the cache. I am assuming you have devel module installed.
function your-theme_name_field($variables){
dsm($variables['items'][0]['#markup']);
return ;
}
You will be able to access the value you are looking for.
这篇关于自定义字段输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!