When creating a views with RSS Feed format the 'language input' is still visible, even though it is hidden in the RSS display settings of the node.

I have a blog content type with a special text field for publishing on social media. I have installed the i18n module, so that each blog post can be to be translated into different languages. By default the i18n module adds the language information (e.g. 'Language = EN' to the content of each node, but you can hide it in the different display modes (full, teaser and RSS).

With the views > Feed display i generate an RSS feed of these special textfields for social media. settings:

Format:RSS Feed | Settings
Show:Content | Use default RSS settings

I understand that if I use the default RSS settings, than i use the RSS settings as defined in the 'manage display' tab of my node type settings. That works fine: the only visible field is the specific text field for social media, and that is the field that shows up in my RSS Feed.

But: although I have hidden the language from the display: Still i the 'language = EN' appears in my RSS Feed.

Comments

dawehner’s picture

Issue tags: -i18n compatibility

All what views does it

     node_build_content($node, 'rss');

as it does node_feed.

But sadly this isn't exposed as "manage display" at least from my perspective, so you seems to be doomed.

dawehner’s picture

        'rss' => array(
          'label' => t('RSS'),
          'custom settings' => FALSE,
        ),

You seems to be not able to alter it.

This seems to be unfixable for me.

dawehner’s picture

Status: Active » Closed (won't fix)

Update status, this would require a fix in core.

Talkless’s picture

Could someone suggest a walk around? How could I remove it "by hand" (regexp) ?

tegerson’s picture

I use "title only" instead of default RSS settings, this gives an empty description-tag. I remove the tag in views-view-row-rss.tpl.php and add it again with Content Templates (http://drupal.org/project/contemplate)

dropbydrop’s picture

Project: Views (for Drupal 7) » Drupal core
Version: 7.x-3.0-rc1 » 7.8
Component: Miscellaneous » base system
Status: Closed (won't fix) » Active

I have the same problem.

Dereine says there should be a fix at core, so this issue should move at Drupal core.

@tegerson. Could you please provide a step by step tutorial on how you do this please?

yannisc’s picture

Looking for a fix too.

mortendk’s picture

This is probably the uglist fix ever but got the job done ...

i basically gave up to figure out where it came from so i used good old str_replace

function THEME_preprocess_views_view_row_rss(&$vars) {
  $view     = &$vars['view'];
  $options  = &$vars['options'];
  $item     = &$vars['row'];

  //print_r($item->description);
  //kills off the language crap that comes from where it is that drupal thinks its a good idea ...  
  $dielanguagedie = array('<div  class="form-item form-type-item">', '<label>Sprog </label>','Dansk'."\n".'</div>', 'Engelsk'."\n".'</div>');
  $languagecleaner = str_replace($dielanguagedie, "", $item->description);

  $vars['title'] = check_plain($item->title);
  $vars['link'] = check_url($item->link);
  $vars['description'] = check_plain($languagecleaner);
//  $vars['description'] = check_plain($item->description);
  $vars['item_elements'] = empty($item->elements) ? '' : format_xml_elements($item->elements);
}

you need off course to go in and change the 'Dansk' & 'Engelsk' from the $dielanguagedie array and change the classes that's added so it match you div classes

its not pretty but it works ;)

kevin morse’s picture

I too am looking for a fix and don't really want to muck with Core...

I have multiple sites running under a multi-site and I would like to share the news from the main one to a few of the sub sites. I figured this would be the easiest method?

nuez’s picture

My solutions was to write a custom module, where you can do exactly what you want.

I wanted to create to feeds, one field with texts for facebook, another field with texts for twitter. The output is two different RSS feeds, you can find at:

yoursite/social/twitter
yoursite/social/facebook

The RSS output you can use to connect with dlvr.it or rssgraffiti to publish on facebook, twitter, etc.

The trick was just to copy the node_feed function (http://api.drupal.org/api/drupal/modules--node--node.module/function/nod...) , give it a different name, and change whatever i wanted to change. instead of using the RSS display of the node, i implemented just the facebook and twitter text fields. you can implement whatever field you want.

its a bit quick and dirty, but its a way to solve it.


function custom_rss_menu() {
  $items['social/%social'] = array(
      'title' => 'custom field',
      'page callback' => '_custom_rss_page',
      'access arguments' => array('access content'),
      'page arguments' => array(1)
  );
  return $items;
}

function custom_rss_contents() {
  global $language;
  $query = db_select('node', 'n')
          ->fields('n', array('nid'))
          ->condition('status', 1) //Published.
          ->condition('type', 'article')
          ->orderBy('created', 'DESC'); //Most recent first.
  return $query->execute();
}

/* get the argument */

function social_load($social) {
  return $social;
}

/* output the page, but only if argument is facebook or twitter */

function _custom_rss_page($social) {
  if ($social == "facebook" || $social == "twitter") {
    $result = custom_rss_contents();
    foreach ($result as $node) {
      $items[] = $node->nid;
    }
    custom_rss_feed($items, $social);
  }
}

/* this function is stolen from node_feeds */

function custom_rss_feed($nids = FALSE, $social) {
  global $base_url, $language_content;

  $item_length = variable_get('feed_item_length', 'fulltext');
  $namespaces = array('xmlns:dc' => 'http://purl.org/dc/elements/1.1/');
  $teaser = ($item_length == 'teaser');
  // Load all nodes to be rendered.
  $nodes = node_load_multiple($nids);
  $items = '';
  foreach ($nodes as $node) {

    $item_text = "";

    $node->rss_namespaces = array();
    $node->rss_elements = array(
        array(
            'key' => 'pubDate',
            'value' => gmdate('r', $node->created),
        ),
        array(
            'key' => 'dc:creator',
            'value' => $node->name,
        ),
        array(
            'key' => 'guid',
            'value' => $node->nid . ' at ' . $base_url,
            'attributes' => array('isPermaLink' => 'false'),
        ),
    );
    // HERE WE ADD SOME NODE VARIABLES

    $link = url('node/' . ($node->nid), array('absolute' => TRUE));
    if ($social == "twitter" && isset($node->twitter['und'][0]['safe_value'])) {
      $item_text = $node->twitter['und'][0]['safe_value'];
    }
    if ($social == "facebook" && isset($node->facebook['und'][0]['safe_value'])) {
      $item_text = $node->facebook['und'][0]['safe_value'];
    }
    if ($node->publish['und'][0]['value'] == 1) {
      $items .= format_rss_item($node->title, $link, $item_text, $node->rss_elements);
    }
    unset($item_text);
    unset($link);
  }

  $channel_defaults = array(
      'version' => '2.0',
      'title' => variable_get('site_name', 'Drupal'),
      'link' => $base_url,
      'description' => variable_get('feed_description', ''),
      'language' => $language_content->language,
  );
  $channel = $channel_defaults;

  $output = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
  $output .= "<rss version=\"" . $channel["version"] . "\" xml:base=\"" . $base_url . "\" " . drupal_attributes($namespaces) . ">\n";
  $output .= format_rss_channel($channel['title'], $channel['link'], $channel['description'], $items, $channel['language']);
  $output .= "</rss>\n";

  drupal_add_http_header('Content-Type', 'application/rss+xml; charset=utf-8');
  print $output;
}




kevin morse’s picture

Should a bug for this also be filed with il8n?

I'm still hesitant to write my own module but I guess I might have too! It really sucks right now to have all my headlines start with Language English. I can't believe this is an issue! It seems like a pretty huge problem to have made it into the release version.

I'm also wondering if perhaps the Content Type / Manage Display menu is broken. In there it provides options for custom display settings for RSS but Language is displayed even though its set to be hidden. I've toggled it on and off and confirmed that other fields can be turned on and off but the Language field appears to be on regardless of whether its turned off or not.

mortendk’s picture

it should
writing a module to remove 1 line is imho a bit overkill would be nice if "it just worked"

DEJU’s picture

@mortendk
Where exactly did you put this piece of code?
(I’m very new to drupal, so all help is welcom;)

mortendk’s picture

its in you template.php file
if you dont have it in you theme just create the file

remember to change the THEME_ to you themesname

dddave’s picture

Version: 7.8 » 7.x-dev
Status: Active » Postponed (maintainer needs more info)

Is this still an issue?

Talkless’s picture

Issue summary: View changes

Just tried with 7.30.

Though Language is set as hidden in RSS display, it's still visible in rss.xml content with "Use default RSS Settings".

If "RSS" is explicitly selected instead of "Use default RSS settings", Language field can be successfully hidden from rss.xml using both Core and Display Suite "RSS" displays.

Status: Postponed (maintainer needs more info) » Closed (outdated)

Automatically closed because Drupal 7 security and bugfix support has ended as of 5 January 2025. If the issue verifiably applies to later versions, please reopen with details and update the version.