Hello,

While trying to find a way to modify the teaser display in DS(see http://drupal.org/node/841188), I found that module.

After trying it on some fields, I really think that I should include it in every Drupal site I do :) Thanks for it, I love it.

I still have a question ! How to do if I want to apply a CF to the body field ?

Thanks!

Comments

deciphered’s picture

Looks like certain changes where made to Display Suite that removed the body field from use in Custom Formatters... or it was never available... but I'm pretty sure it was.

Replace the 'nd_custom_formatters_fields_alter()' function in 'custom_formatters/modules/nd.inc' with the following code:

function nd_custom_formatters_fields_alter(&$fields) {
  foreach (module_implements('ds_api') as $module) {
    $api_info = ds_api_info($module);
    $extra = array();
    foreach ($api_info['extra'] as $key) {
      $extra[$key] = 1;
    }
    foreach (ds_get_fields('nd', NULL, NULL, $extra) as $key => $field) {
      if ($field['type'] == DS_FIELD_TYPE_THEME || $field['type'] == DS_FIELD_TYPE_CODE) {
        $fields['nd_' . $key] = array(
          'label' => $field['title'],
          'module' => 'nd',
        );
      }
    }
  }
}

Will be committed shortly.

Cheers,
Deciphered.

pol’s picture

Thanks for your code, indeed, I can see the nd_stuff now.

Thanks also to swentel who helped to find which variable to edit.

Here is an example of CF body:

return substr($element['#item']['body'], 0, 10) .' ... ';

Thanks!

BenK’s picture

Subscribing...

mrfelton’s picture

Status: Active » Needs review
StatusFileSize
new1.26 KB

Patch attached. Thanks

I used the following for my custom teaser

return _filter_htmlcorrector(trim(truncate_utf8(str_replace('<p>', '', str_replace('</p>', '<br />', strip_tags($element['#item']['body'], '<p>'))), 200, TRUE, TRUE)));
deciphered’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.