0

I am writing a cck-widget/field and formatter. My field-settings contains a "base_url" setting. If I draw that out:

http://example.com/ [_some/path/to/a/file.avi________]

http://example.com is the base_url. some/path/to/a/file.avi is what user provides and gets stored in database.

The formatter should append that base_url to the user-supplied values:

function theme_video_url_formatter_embed($element) {
   return "$element['base_url']/$element['#item']['safe']";
}

How can I pass the variable from field-setting $base_url along, so it ends up in that formatter-theme-function?

2

You can take number.module from the CCK package as an example; it allows prefix and suffix values in the field settings that are rendered in the formatter.

In theme_number_formatter_generic() the field settings are retrieved using $field = content_fields($element['#field_name'], $element['#type_name']);. The values are then taken from the $field array, sanitized and added to the output.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.