1

I am using Drupal 7 and Views 3.0-RC1.

I have defined an RSS feed for a view, but the full node content keeps showing up instead of the teaser. I believe it is because of these two issues:

The steps that appear to work are to:

  • Enable a custom display for RSS,
  • Configure the RSS custom display truncate the teaser and hide extra fields,
  • Enable the view to display full text for RSS.

I need to make this work programmatically as part of a features module.

The first step is easy. I do it with the following code in my .module file:

    function mymodule_entity_info_alter(&$entity_info) {
      $entity_info['customtype']['view modes']['rss'] = array (
        'label' => t('RSS Feed'),
        'custom settings' => TRUE,
      );

The last step is easy, as I can export the view.

The middle step has me stumped. I can't figure out how to set the display properties on the RSS display. I suspect it has something to do with field settings, but I can't seem to pull the pieces together. Any suggestions?

1 Answer 1

1

@JeremyFrench pointed out that the Features Module correctly exports the field settings for the view-mode, which fulfilled the middle step. No extra API calls is necessary.

My problem was with step 1. Though field settings are defined per-content-type and per-view-mode, the actual definition of view modes is independent of content-types. All content types share the same set of view modes, though each can implement their own field settings for that view mode.

This means that in my call to hook_entity_info_alter(), I should not have referenced customtype, I should just reference 'node'. That simple change enables everything to work.

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.