Linking to feeds item URL

mattie's picture
mattie
Fri, 03/22/2013 - 09:19
#1
Linking to feeds item URL

I'm using the Feeds module to aggregate RSS feeds from different sources, and I'd like to use this theme for the task. How do I make the Title, Image and "Read More" links map to the original source URL for feed items? That is, I don't want them to link to Drupal nodes. I want them to link to the external links associated with the feed items.

I've attached a screen shot here with one example to illustrate the point, and I'm happy to provide additional screen shots and/or provide any additional information you may need.

mattie's picture
mattie
Sat, 03/23/2013 - 13:17

I've found a couple of pieces of information that look promising, but I'm not sure how to integrate the code into the back end:

 

Neo's picture
Neo
Mon, 03/25/2013 - 06:21

Hi Mattie,

  1. First, you need to go to Structure -> Content type -> Feed item and add new text field, call Source (marchine name: field_source)
  2. Then go to Structure -> Feed importer
  3. Click "Mapping" at Node processor
  4. Select a source "Item URL (link)" and Target is "Source" (field that was created in step 1)
  5. Click Add and Save
  6. Now go to sites/all/md_thenews/templates and copy node--article.tpl.php to node--feed-item.tpl.php
  7. Clear site cache
  8. Edit node--feed-item.tpl.php :
    Find <?php print $links; ?>, replace with:

<ul class="links inline"><li class="node-readmore first"><a href="<?php print $node->field_srouce['und'][0]['value'];?>" target="_blank">Read more</a></li></ul>Remember to delete all existing feed item nodes, because they did not have field_source value.

mattie's picture
mattie
Wed, 03/27/2013 - 10:57

Hi, Neo:

After copying file node--article.tpl.php to node--feed-item.tpl.php I lose the ability to edit feed items in the manner shown below, and it's important for me to retain this functionality. How specifically do I accomplish this?

Edit feed item

 

Neo's picture
Neo
Wed, 03/27/2013 - 11:43

you mean this function disappear? Can you upload your node--feed-item.tpl here?

mattie's picture
mattie
Wed, 03/27/2013 - 11:50

Yes, I mean this function disappears. I disabled it for purposes of creating that screenshot, but I'll put it in place again and upload it for you here in a couple of minutes.

Stay tuned,

Mattie

mattie's picture
mattie
Wed, 03/27/2013 - 12:04

I've reverted to a simplest use case to illustrate the problem, and I've uploaded the node--feed-item.tpl.php here. All that I've done is to copy file node--article.tpl.php to node--feed-item.tpl.php and clear cache. Again, for purposes of demonstration, I haven't put the mapping changes into place (although I have done so previously with the same result).

 Note: I had a little difficulty uploading the file here, so it's been renamed. On my server, the file name is node--feed-item.tpl.php. Apologies for any confusion.

Neo's picture
Neo
Wed, 03/27/2013 - 12:40

it's my bad, please follow this instruction:

before line 8: <h2<?php print $title_attributes; ?> class="article-title">

add <?php print render($title_prefix); ?>

after line 10: </h2>

add: <?php print render($title_suffix); ?>

do the same with line 27 and line 29

mattie's picture
mattie
Wed, 03/27/2013 - 17:15

That worked -- it's a beautiful thing. Thanks!

mattie's picture
mattie
Thu, 03/28/2013 - 11:55

Hi, Neo:

I'm not out of the woods yet. The feed item editing functionality is in place, and I've got the title and "Read more" links pointing to the external source URL rather than the node. The last piece of the puzzle will be getting teaser images to display and have them properly linked to the external source URL as well. (Have a look at the very first screenshot at the top of the thread if that description confused you.)

I have IMCE modules installed to assist in production work, and I've enabled IMCE usage for image fields in both feed item and article content types. However, when I edit a feed item to upload and incorporate images (using one of the theme options), it's saved fine but doesn't display in the teaser view. I have a suspicion that this is related to the $articleimage variable in the node--feed-item.tpl.php template looking for data from the article type field data rather than the feed item content type data.

I'll put together a quick screencast for illustrative purposes if you'd like, so let me know if that would be helpful to you.

Best -- Mattie

 

Addendum: I did create a screencast for you, so check out  http://youtu.be/oUavRcBu9PY if you feel it would be helpful.

Log in or register to post comments
Have More Idea?

We are here to build your website!

No Universal solution fits all special business requirements. Our experienced team is ready with ideas and state-of-the-art technical solutions to consult the best solution within your budget.