I'd like to map the title and link of the RSS feed (not each feed item but the title and url at the top of the feed) to a field in each post. I have read a few issues on similar topics but I'm not sure they are trying to do exactly this. Is this possible at the moment? I can't seem to find it anywhere

If it is not possible to do that as a workaround I was thinking of entering the information manually as a CCK on the feed node and using that to map to every feed item created from that feed. Can someone please point me to the function that needs to be altered of overridden.

Thanks for your help.

EDIT: for D7 look at #1689374: Map feed Title and feed URL

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

alex_b’s picture

Category: support » feature

This feature would require restructuring and expanding the mapping API pretty significantly (how exactly I haven't figured out yet...). Unfortunately using a CCK field won't buy you anything. A good feature request though.

a_lawry’s picture

Thanks for the reply Alex. I'll have a look into the code and see if I can come up with a solution for my project.

a_lawry’s picture

I changed the code myself. Added some lines to the process function of FeedsNodeProcessor to load the feed node read the cck field values and add them to the feed item node just before node_save() was called.

Would it be worth providing a hook for this kind of thing? So in the future people can write a module to post process the feed items before the node is saved. Then they can pull data from wherever they like.

alex_b’s picture

#3: do you want to post your modifications as a patch?

a_lawry’s picture

It's probably not worth it. My changes were so specific to what I needed that it couldn't be used by anyone else. At best it would serve as an example of how I hacked it to get my functionality done. What do you think?

alex_b’s picture

#5 Worth it :-)

Marc Ledergerber’s picture

Issue tags: +CSV import

Any thoughts on how to enable taxonomy support for mapping fields using "Feed Node processor" when importing from local CSV file with standalone form?

Have you tried this? http://drupal.org/node/862874

seanberto’s picture

I'm looking map the title field to the feed field too. One of the benefits being that I can then use the editview module to provide a nice UI for editing a bunch of feed URLs in a single view.

I think that the quickest way to do this will be to write a little custom module that uses a hook_nodeapi call and a hook_form_alter for nodes of a given content type.

I can then package the custom module, content type definition, views definition, etc. into a little feature. My ultimate goal is to create a blogging feature that allows a blogger to quickly/easily maintain a list of feeds that all populate his/her blog. The current Feeds UI is great - but a bit too complex for my clients.

(Thanks for this great module!)

seanberto’s picture

Whoops, this isn't quite as easy as I thought, as Feeds seems to be doing it's own "title field" validation on the node add/edit forms. Exploring.... I'll post my solution.

apes132’s picture

I too am looking to get this functionality. has anyone come up with a patch?

alex_b’s picture

Version: 6.x-1.0-alpha12 » 6.x-1.x-dev
Issue tags: -CSV import +Novice

Since #632920: Inherit properties from parent feed node (taxonomy, author, OG, language) got committed we are ***much*** closer to this feature request. All that needs to be done is to expose title, description, etc. via FeedsParser::getMappingSources() and set them via FeedsParser::getSourceElement().

This is a novice task.

bee2b’s picture

Any updates adding the feature to the next release of feeds?

mstrelan’s picture

I think what alex_b is suggesting in #11 is something like below.

Index: sites/all/modules/feeds/plugins/FeedsParser.inc
===================================================================
--- sites/all/modules/feeds/plugins/FeedsParser.inc	(revision 8011)
+++ sites/all/modules/feeds/plugins/FeedsParser.inc	(working copy)
@@ -53,6 +53,10 @@
     if (!feeds_importer($this->id)->config['content_type']) {
       return $sources;
     }
+    $sources['parent:title'] = array(
+    	'name' => t('Feed node: Title'),
+      'description' => t('The feed node title.'),
+    );
     $sources['parent:uid'] = array(
       'name' => t('Feed node: User ID'),
       'description' => t('The feed node author uid.'),
@@ -82,8 +86,13 @@
    * @see FeedsCSVParser::getSourceElement().
    */
   public function getSourceElement(FeedsImportBatch $batch, $element_key) {
-    if (($node = node_load($batch->feed_nid)) && $element_key == 'parent:uid') {
-      return $node->uid;
+    if ($node = node_load($batch->feed_nid)) {
+      switch ($element_key) {
+        case 'parent:title':
+          return $node->title;
+        case 'parent:uid':
+        	return $node->uid;
+      }
     }
     $item = $batch->currentItem();
     return isset($item[$element_key]) ? $item[$element_key] : '';

I think however what the OP (and myself) are after is the Title and URL from the RSS feed itself, rather than the Drupal node that imports the feed. For example if you look at http://drupal.org/node/feed you will notice the following before any tags

<channel>
 <title>drupal.org</title>
 <link>http://drupal.org</link>
 <description>Drupal.org is the official website of Drupal, an open source content management platform.  Equipped with a powerful blend of features, Drupal supports a variety of websites ranging from personal weblogs to large community-driven websites.</description>
 <language>en</language>

...

</channel>

Is there a way we can expose this information?

mstrelan’s picture

OMG I forgot to dpm the $batch variable. Please ignore #13, patch incoming.

mstrelan’s picture

Status: Active » Needs review
FileSize
2.36 KB

Ok lets try again. Patch attached, first time on GIT so forgive me if I did it wrong. Has been tested mapping the title field from http://drupal.org/taxonomy/term/8/feed/feed to a text based CCK field and it worked perfectly for me. Let's hope this can get in quickly.

krem’s picture

Hi there,

Thanks mstrelan for your patch, it has been a great help !

Still, I patched my 6.x-1.0-beta11 feeds module but it didn't work for the parent node title :

if ($node = node_load($batch->feed_nid) && strpos($element_key, 'parent:') === 0) {
      switch ($element_key) {
        case 'parent:title':
          return $node->title;

I had to set the $node variable within the condition :

if ($node = node_load($batch->feed_nid) && strpos($element_key, 'parent:') === 0) {
      $node = node_load($batch->feed_nid);
      switch ($element_key) {
        case 'parent:title':
          return $node->title;

I realise $node is set in the if condition but I could not access it... I'm curious why through, I'm not used to this kind of code in a "if" condition, if somebody has some php knowledge to share, please do!

planstoprosper’s picture

The && and === operators both have higher precedence than the = operator. The line

if ($node = node_load($batch->feed_nid) && strpos($element_key, 'parent:') === 0) {

needs to include parentheses around $node = node_load($batch->feed_nid).

if (($node = node_load($batch->feed_nid)) && (strpos($element_key, 'parent:') === 0)) {

That's why krem had to set $node again.

geek-merlin’s picture

for the corresponding d7 issue look here: #1689374: Map feed Title and feed URL

Yura’s picture

#17 wrapped in parentheses

Yura’s picture

Issue summary: View changes

added d7 link

twistor’s picture

Issue summary: View changes
Status: Needs review » Closed (outdated)