Customize a field output

流过昼夜 提交于 2020-01-17 05:17:29

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/5835392/customize-a-field-output

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!