1

I added a views adn feed type display for news. I want to customize the rss page. Currently it displaying like this :

<channel>
    <title> </title>
    <link> </link>
    <description></description>
    <language> </language>
          <item>
    <title> </title>
    <link> </link>
    <description> </description>
     <pubDate> </pubDate>
 <dc:creator> </dc:creator>
 <guid isPermaLink="false"> </guid>
  </item> 
</channel>
</rss>

When i check it in firebug it includes in <pre> tag. But i want to customize it by css how to do that? How to remove <pre> tag?

2

There's a few issues confused into here based on the original question. I'll try to take these one at a time:

1 Is RSS the same as HTML?

No, these are different markup languages. RSS is a dialect of XML designed for syndicating content from podcasts, blogs, etc, etc. HTML is a web page specific markup format. In your question you mentioned that firebug is showing a <pre> tag in RSS feed, but this is impossible because <pre> is HTML only, and will never appear as RSS.

2 How can I style an RSS feed?

Typically, you don't need (or want) to do this. RSS Readers typically apply formatting to your RSS content, and if you change the formatting this could get confusing and ugly for your end users. Just as there are many browsers for HTML, there are many RSS REaders for RSS including iTunes, online services, Mozilla Thunderbird and hundreds of others. So, I recommend NOT styling your RSS feed.

However, if you need to style an RSS feed you can do using regular CSS by adding this tag to beginning of your RSS feed:

<?xml-stylesheet type="text/css" href="http://example.com/rss.css" ?>

Then you would need to create a css file called rss.css in the appropriate place on your server. Here's a great article that goes more in depth on this: http://www.petefreitag.com/item/208.cfm

3 How do I get Drupal to modify my RSS feed to include CSS?

This is really a great question, and a lot of people struggle with this. What makes this hard is that in Drupal 6 and 7 only HTML can be "themed", so many of the normal hooks that work on nodes which appear as HTML do not work on RSS feeds. What's also really anooying is that Drupal will escape all your HTML markup and put it inside your RSS feed, making your RSS feed nearly unreadable.

If it doesn't exist already, create a new folder called template inside your theme folder. Add a new file inside that folder called views-view-rss.tpl.php. This file will affect all your RSS feeds. Add this code inside views-view-rss.tpl.php:

<?php
/**
 * @file
 * Default template for feed displays that use the RSS style.
 *
 * @ingroup views_templates
 */
?>
<?php print "<?xml"; ?> version="1.0" encoding="utf-8" <?php print "?>"; ?>
<?php print "<?xml"; ?> type="text/css" href="http://example.com/rss.css" <?php print "?>"; ?>
<rss version="2.0" xml:base="<?php print $link; ?>"<?php print $namespaces; ?>>
  <channel>
    <title><?php print $title; ?></title>
    <link><?php print $link; ?></link>
    <description><?php print $node->body['und'][0]['value']?></description>
    <language><?php print $langcode; ?></language>
    <?php print $channel_elements; ?>
    <?php print $items; ?>
  </channel>
</rss>

For more details on this: https://drupal.org/node/1884558

4 How do I remove a specific tag from my RSS feed?

It depends on where the tag is appearing in your view. I assume it's showing up inside <item> tag somewhere. In the file you created earlier, change:

    <?php print $items; ?>

to:

    <?php print str_ireplace(array('<pre>','</pre>'), '', $items); ?>

Make sure to clear the cache.

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.