Hi All,

I have problem with RSS. I proceed RSS with standart module in Drupal. I have RSS-file (See please http://www.dm-st.ru/rss.xml ) but all image in this file have relative links. When I translate my RSS chanel to other sites (for yandex.ru for example) all images was lost. :( I need absolute link in file rss.xml .

I see two decision:

1) Transfer relative to absolute links of images in editor (not right)
2) Transfer relative to absolute links of images when Drupal process RSS file. (I prefer this variant).

How I can correct RSS function in Drupal?

regards Aleksey,

All about minitractors & tilles www.dm-st.ru

Comments

Nick Lewis’s picture

Drupal's RSS feeds are agnostic to the links in $node->body after its saved. If you enter a relative path in a wysiwyg editor, that's what you'll get in the RSS feed. That said, you could do theoretically convert the links within hook_nodeapi($op = 'rss item'), but you'll need either some simpleXML, or preg kungfu to find, and replace the bad image links. Or you could create filter that automatically converts the links when you save, but if your not in the mood to do development, i'm afraid you're SOL.

--
"I'm not concerned about all hell breaking loose, but that a PART of hell will break loose... it'll be much harder to detect." - George Carlin
--
Personal: http://www.nicklewis.org
Work: http://www.onnetworks.com

--
"I'm not concerned about all hell breaking loose, but that a PART of hell will break loose... it'll be much harder to detect." - George Carlin
--
Personal: http://www.nicklewis.org
Work: http://www.zivtech.com

dmstru’s picture

But I don't understand where and what I must correct concreate. I am sorry, but I am not programmer.

with best regards Aleksey
All about minitractors & tillers www.dm-st.ru

dmstru’s picture

who can help me?

with best regards Aleksey
All about minitractors & tillers www.dm-st.ru

dmstru’s picture

What function process rss.xml file?

with best regards Aleksey
All about minitractors & tillers www.dm-st.ru

edelwater’s picture

I came here because I noticed that Drupal feeds all had relative paths and so screwed up my friends-feed php reader thing. I do not know Drupal but it seems that in 2004 a decision has been taken to make all paths relative and use base path in the theme because it would help moving to another url (while a mod rewrite could do the same?).

So began searching for more Drupal feeds and noticed an awful lot of them were simply not "clickable", the urls were missing before href, src etc... couldnt see the images, not really helpful for any SEO adventures I think actually not good at all.

Because I only have a fixed sites of Drupal sites I simply can check if the rss feed is from friend X and then manually add the base url in his feed to every href and src so the images show again.

Isn't this awfully weird? What's the purpose of an RSS feed according to Drupal devs? Is the purpose that any non-drupal site which likes to incorporate rss feeds has to write their own "oh oh a Drupal RSS feed" filter?

Aleksey, here is something to get started for the a hrefs, but the concept will work for other stuff:


// can be directly copied and pasted from the php site manual pages:

function strxchr($haystack, $needle, $l_inclusive = 0, $r_inclusive = 0){
   if(strrpos($haystack, $needle) !== false){
       $left =  substr($haystack, 0, strrpos($haystack, $needle) + $l_inclusive);
       $r_inclusive = ($r_inclusive == 0) ? 1 : 0;
       $right =  substr(strrchr($haystack, $needle), $r_inclusive);
       $a = array($left, $right);
       return $a;
   }else{
       return false;
   }
}


function Replacer($matches) {
    $or_string  = '<a href="' . $matches[1] . '">' . $matches[2] . '</a>';
    $st_string  = '<a href="|YOURBASEURLSITE|' . $matches[1] . '">' .
    $st_string  = $st_string .  'MAYBE SOME ADDITION WARNING ICON: LIKE "OH OH A DRUPAL HREF MAYBE NOT OK...." ';
    $st_string  = $st_string . '</a>';

 ---> Aleksey: this stuff is for hrefs which have weird long stuff in it which contains sometimes even hrefs in themselves (could break the thing):
    if (strstr ( $matches[2], '<' )) {
      return $or_string;
    } else {
      
      return $st_string; // but could include $or_string for debugging....
    }
}

function addstuff ($text) {
    return preg_replace_callback('/<a href="(.*?)">(.*?)<\\/a>/i', 'Replacer', $text);
}

I think this hook you have in Drupal could call addstuf with the $rss things it passes.

You can add any other replacements you like by varying the replacers.

IF all of this has been discussed many times and there are already Drupal modules who do this then disregard my grmlb-ness.....

IF a helper "module" (is that what is named in Drupal) does not exist for solving this HUGE problem (at least for the non drupal rss feed readers (humans)) then email me so I can add it somewhere in the code lib.