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?

1 Answer 1

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 this code.

$field = content_fields($element['#field_name'], $element['#type_name']);`

The values are then taken from $field, sanitized, and added to the output.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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