📜 ⬆️ ⬇️

Drupal API, formatted output of CCK fields

So, I am sure that each of us, when raising a regular project with an original design on Drupal, faces the problem of formatted output of various types of CCK fields in the required place on the page and in the right order. For these purposes, we do not at all suit the alignment of the fields implemented on the Manage fields page, especially if we want to build them in the form of adding material and in a template in various ways. Formatting with CSS sometimes saves, but not always, and pulling fields from the variable $ node or from the variable field $ field_field_name and writing a handler directly in the node-nodetypename.tpl.php template is often masochism (although in some cases this may be justified decision, but it is rather an exception).

I found a simple and natural solution based on the Drupal API:

print content_view_field(content_fields('_','__'),$node);

This line will output a formatted CCK field with a label or without a label, depending on what parameters you set on the “Display fields” page, in the control system.
')
Thanks for attention.

Source: https://habr.com/ru/post/65633/


All Articles