By Anonymous (not verified) on
I have the following situation:
My customer wants, that content creators/editors stay anonymous to the public. While it is no problem to hide the information in HTML, I can't seem to figure out how to alter or hide the dc:creator tag in RSS, without modifying Drupal's core code.
Comments
Subscribing
I'm having the same problem. No ideas? Another thing I'd like to do is add the content type to the rss feed (title or description) in a feed made with views.
My solution: Create a module
My solution:
Create a module (for example mymodule) and implement a nodeapi hook. Nodeapi gives you ability to modify RSS feeds ($op=='rss item'). Example:
hope it helps.
----------------------------------------
Boldizsár Bednárik ing.
http://www.bboldi.com
Single Feed
Nice workaround bboldi, it works for me. One more question though: Is it possible to apply your method to a specific RSS feed? This way the modification is applied for the node type in every RSS feed. It'd be perfect to have the change just in one feed, in case the node appears in various feeds.
$_REQUEST['q']
To answer my own question: I achieve this by adding an if-statement that checks the feed URL:
It works, I'm not sure if it's written nicely, though.
thanks bboldi it works well
thanks bboldi
it works well for me for changing the teaser since we use a different cck field for our teasers.
Teaser not updating
Hello,
I have a content type called 'article' and I included the title in my teaser, so now on the rss feed the title is displaying twice. I'm trying to remove the title from the teaser so that it doesn't show in the rss description, so I created a module based on your above code, but for some reason the teaser is not updating. I can update the title fine, but the teaser still displays the contents from my mytheme_article_teaser function. Here is my code to redefine my article teaser without the node title:
Any ideas?
Thanks!
Great snippet - works a treat.
Replace PubDate
Thanks for the solution,
can you give a sample how to replace PubDate with cck date field?
Thanks
Thanks for the suggestion.
Thanks for the suggestion. Tracking this thread in case there are any other ideas.
Can you give an example?
Can you give me an example of how you implemented the above module? I'm trying to pull in some extra CCK fields into my RSS feed, but according to http://drupal.org/node/118833 it's not possible out of the box with Views / CCK / Contemplate.
I need my RSS feed items to look more like this:
Is something like this even possible, I've spent all day on it and hit a dead end every time....
The greatest strength is knowing your greatest weakness.
I'm trying to do the same
I'm trying to do the same thing, the only way I could think of was making a list view and reformatting it with php to rss, then print and exit() before the layout is output. It didn't work, though. Now I'm digging inside the views module code for something usable, and found a function called _views_build_query(), which returns an array with the query, a count query and all of the arguments. Ran it through db_query() or db_query_range() and then parsed the result myself.
Note: this approach returns only the fields specified in the view. Below I use print_r() instead of writing XML.
You could duplicate the views-rss module and implement this mehtod, or use it wherever you can execute php.
I found information on this
I found information on this at http://groups.drupal.org/node/9044.
Jeremy
Removing publishing date from RSS feed
Problem with our events guide feed: it's listing the publishing date on the line below the event title, giving the impression that the publishing date is the date of the event.
we're looking for a way to customise the view and remove the publishing date from the feed entirely. any help on this? view the feed here: http://new.overtone.co.za/cape_town_event_rss
Removing "dc: creator" (or other) from RSS feed items
How would one adapt the code examples to hide a specific item from the RSS feed, like the dc: creator tag as originally asked in this thread?
I hope someone can clarify how to do this in Drupal 6.
Removing "dc: creator" and other
Try http://drupal.org/project/contemplate (great module allows theme rss and much more, but still display creator and pubDate ), so in views/modules/node/views_plugin_row_node_rss.inc -> comment line "array('key' => 'pubDate', 'value' => gmdate('r', $item->created)), array('key' => 'dc:creator', 'value' => $item->name)"- I know, very not elegant solution
That's exactly what I did ;)
though I forgot to post it here...
Maybe at some point someone will come up with a better solution...
Alternate approach
Based on bboldi's code above, I used
$node->name = '';to remove the username (dc:creator) from the RSS items. So, I created a custom module with the following code in the .module file:This will not remove the dc:creator tag entirely, but it shows as empty in the xml. I believe that doing the same thing with $node->created would meet the need of removing the timestamp from the feed, though, I would guess that having some sort of timestamp for a feed is a good idea. I'm not sure what you would set it to, whether it is a date or a string or whatever.
This approach worked for me
This approach worked for me with 6.19. In my case, I did not want to remove author but rather replace it with the contents of a CCK field. Seems to work fine, I haven't found any problem.
With Themes
On Drupal 6:
Put "views-view-row-rss.tpl.php" in your theme directory and replace
print $item_elements;with
You can use the same approach to insert other items
ereg is deprecated in PHP 5.3+
ereg is deprecated in PHP 5.3+
But you can achieve the above using preg, like so:
I've a short blog post about this here..
============
Drupal Core Maintainer for "Out of the Box" Initiative.
You are not wrapping your
You are not wrapping your regex in delimiters, so I believe that code will throw errors.
Contact me to contract me for D7 -> D10/11 migrations.
Changes in Drupal 6?
I've been trying to apply some of these changes to an RSS feed on my Drupal 6 site. Specifically, I'm using the node comment module--and I'm attempting to make a RSS feed for comments. The feed builds fine, but since comments are now nodes the link in the rss feed takes you to the comment node, rather than the parent node.
I've been trying to use nodeapi to override and change some of the rss settings with this function:
This code will modify the Body on the node of any rss item, and as you can see I have the body modified to print out the full node object. In this printout the Title and Path will be changed to my custom setting, however in the rss feed the title and path do not change.
Does anyone have any idea what might be going wrong here? It doesn't make sense to me...i figure I'm just doing something wrong.
thanks-
changing the path of rss feed items for node comments
If anyone searches for rss, node_comments module, feed, path etc. here's my status on creating this rss feed.
For some reason, I can't get the following code to work...although it seems like it should.
For some reason my views rss feed isn't being modified by this hook. At least not consistently. I'm still working on it.
In the meantime I just added a javascript redirect to my node-comment.tpl.php file
This is working for now.
I've been trying to remove
I've been trying to remove taxonomy terms and modify the title in my module's hook_nodeapi "rss item" operation, but this has no effect.
It looks like views is assembling link and title BEFORE the hook_nodeapi "rss item" operation. From views_plugin_row_node_rss.inc:
So any alteration of those presumably needs to be done in the "alter" operation. But in that case it's unclear how we might determine if the node is about to be included in an rss feed, or if this is some other node view that we don't want to mess with. Ouch.
I can't really see any good reason why views should be making this distinction. Title and link could be added to $item after the "rss item" operation, since $item isn't passed in there anyway, so nothing else gets a chance to modify them.
We can modify or add stuff in $item->elements (ie $item_elements in the view template file) by returning an appropriate array from hook_nodeapi "rss feed", ie:
would set all author names to "foo". But that doesn't help us with title or link.
But I still can't see where the node's taxonomy terms are getting added to the $item->elements array.
Hmm. I'll poke around a bit more then file a request for clarification in the views issue queue.
Thanks for your investigation
Thanks for your investigation John - it was very useful.
Your suggestion for changing the contents of $item->elements doesn't actually work, as the changes you make are added to the xml, rather than replacing the field you are trying to change. I tried this for the creator using your code, and ended up with two "" tags for each entry.
You can however set the creator field by setting $node->name.
Also, note that even if the 'rss items' nodeapi hook was called before the $item object was configured, you would not be able to set the link in hook_nodeapi. This is because the link is being constructed using:
For my purposes I was hoping to set the RSS link to an external site, and it doesn't look like that is going to be possible without some pretty heavy hacking..!
Here's some code to alter an
Here's some code to alter an RSS item's title, creator, and link via a custom module.
(I just posted this in the related issue at http://drupal.org/node/773400#comment-3047550 but thought it might be useful to copy here.)
Don't forget to clear your cache so that the preprocessor function gets recognized.
Oops, array_merge expects an
Oops, array_merge expects an array of arrays, so in hook_nodeapi() use this line instead:
And the preprocessor can be replaced with this:
Its not working.
Hi,
I have tried below code. But no luck. Why print_r($vars) its not working?
I have also cleared cache.
Use this:<?phpfunction
Use this:
Contact me to contract me for D7 -> D10/11 migrations.