Jump to content
ryan

RSS Feed Module

Recommended Posts

You could use FieldtypeConcat for that job, so you even wouldn't need to have the foreach loop.

Share this post


Link to post
Share on other sites

thanks,

but to make things more complicated i only need to do it sometimes, not on all items... So if possibly I'd want to loop over the items.

not sure what happened with the double post, but thanks for deleting it

J

Share this post


Link to post
Share on other sites

Another thing to your entry post, please use the code boxes for code.

foreach($myPages as $p) {
  $p->set("your_new_field", $p->field.$p->anotherfield); //Field is runtime only
}

Maybe this works. You'd need to fill the field for each page. Even if it's different contentwise.

  • Like 1

Share this post


Link to post
Share on other sites

Hi

Is there any way to add fields to the feed for each item? I might have missed something really obvious but I can't figure this out.

Loving processwire so far!

Share this post


Link to post
Share on other sites

To all those with special cases. Why not just create an Rss manually? Few lines of code really. If after all you have to loop them anyway I don't see why use a module for it.

  • Like 1

Share this post


Link to post
Share on other sites

Ah thanks Soma! Just wanted to confirm that there's no way to do this before I manually coded my own RSS feed.

Share this post


Link to post
Share on other sites

Hi, sorry if this already has been covered, but I just stumbled over an issue:

If the pages in

$items = $pages->find(....)

use a template that has no template.php file in /templates/, then nothing will be returned by the

$rss->render($items)

Even though $items is fetched correctly and could be debugged like var_dump($items[0]->title) ...

The strange thing is, only the template.php file needs to be there, even if it's empty.

Since the $rss->render() is used on a different template anyway (for showing the rss"page"), there shouldn't be a need to have the template for the "fetched" pages…?

cheers,
Tom

Share this post


Link to post
Share on other sites

yeah, ran into this issue recently and was banging my head against a wall until i realized my items needed a template, because the rss feed needs a link for the items;

in my case, the template for the RSS item does a simple redirect to it's parent page with a hash to the id of the item (it is an event listing).

if you don't have a template for the RSS item, how would people click on the link to your item?

  • Like 1

Share this post


Link to post
Share on other sites

ah. ouch. I see. :-)

well… in my case I have a setup where I make a distinction between the place where the items are stored/edited and where they are displayed…

- home

 -- News

   -- (article) (used for display)

   -- (rss) (used for the rss)

...

- News-Admin (template=news)

 -- My News 1 (template=article)

 -- My News 2 (template=article)

 ....

So I have the page "News" with urlSegment…  /news/article/my-news-1/

which will display the correct news.

so the item-link in the rss should be /news/article/{$item-name}…

now, with the needed article.php (which is empty) in place, the link in the rss is /news-admin/my-news-1/

I simplified my set-up, in reality there's a lot more bundled under the "administration" page in the tree, not only "news-admin".

hm. I think it will be easier to make the rss output by hand and not using the module, then :-)

EDIT: Thanks for the idea with the redirect on the item's template. Works like a charm for my set-up. :frantics:

Share this post


Link to post
Share on other sites

I’m using ryan’s RSS Feed Module and using the body field as Default Feed Item Description Field in the configuration.

I have blog posts with images, and the image URLs are relative. The W3C Feed Validation Service suggests, that it would be better to always include absolute URLs.

Long story short, how can I transform relative URLs from a textarea field into absolute ones?

Edited by LostKobrakai
Moved to support topic

Share this post


Link to post
Share on other sites

Hi there,

I got that issue, that it always renders a "1" at the end of the feed.

Feed outpu looks like:

</item></channel></rss>
1

My PHP looks like this:
 

// retrieve the RSS module
$rss = $modules->get("MarkupRSS");
// find the pages you want to appear in the feed.
// this can be any group of pages returned by $pages->find() or $page->children(), etc.
$items = $home->children('template=post')->reverse()->find('start=6');

// send the output of the RSS feed, and you are done
echo $rss->render($items);

Thanks

Share this post


Link to post
Share on other sites

i installed the module and used this in my template:

$rss->title = "Latest updates";
$rss->description = "The most recent pages updated on my site";
$items = $pages->find("limit=10, sort=-modified");
$rss->render($items);
 
now i'm getting an error for the last line:
 
Error: Call to undefined method stdClass::render() (line 11 of /var/www/vhosts/***/httpdocs/tmp/site/templates/feed.php)
Edited by kongondo
Moved your topic to MarkupRSS support thread

Share this post


Link to post
Share on other sites

you would need to instantiate the class first, e.g. call the module into an object:

$rss = $modules->get("MarkupRSS");
  • Like 2

Share this post


Link to post
Share on other sites

thanks Macrura

i did an now this. ???

sorry, but i don't know where that should be 

This page contains the following errors:
error on line 46 at column 106: Attribute alt redefined

Share this post


Link to post
Share on other sites

that call would go right before your other settings; also make sure that your $items returns some pages

  • Like 1

Share this post


Link to post
Share on other sites

Hi,

in my new project there are some pages which are only included in an overview page by $page->render($options) and can not be shown as an independent page, I'll call them "sections". I'm using the limit-selector string and the pagination...

Now I would like to refer to special sections which are split by a pagination--> e.g. RSS-link should look like this: domain.tld/sub/page3

Actually I solved it this way:

rss.php template

foreach ($items as $item) {
   
	$item_parent = $item->parent;
	
	if ($item->template == 'my-section-template') {

		$limit = 3;

		$children = $item_parent->children('sort=sort');
		$item_pos = $children->getItemKey($item) + 1;
		
		$pagination_nr = ceil($item_pos / $limit);	
		
		$item->httpURL_mod_wg = $item->parent->httpURL . 'page' . $pagination_nr;
		
	}//end if
}

module modification (the bad way, I know):

protected function renderItem(Page $page) {
	....
	if(!$page->httpURL_mod_wg) $page->httpURL_mod_wg = $page->httpUrl; // inserted by WG
	
	$out = 	"\t<item>\n" .
        "\t\t<title>$title</title>\n" .
        "\t\t<description><![CDATA[$description]]></description>\n" .
        $pubDate . $author . 
        "\t\t<link>{$page->httpURL_mod_wg}</link>\n" . // $page->httpUrl modified to $page->httpURL_mod_wg
        "\n\t<guid>{$page->httpURL_mod_wg}</guid>\n" . // $page->httpUrl modified to $page->httpURL_mod_wg
        "\t</item>\n";

	return $out; 
}

It would be nice if there was a way to modify the <link> and <guide> urls for each Feed Item!

Or maybe someone has a simple solution for this?

Thanks Robert

 

Share this post


Link to post
Share on other sites

I've taken over a site from a developer and it's on processwire.  I'm trying to activate RSS and I've followed the instructions but I keep getting this error:

error on line 1 at column 1866: xmlParseEntityRef: no name

I think maybe it's appending a header or footer and causing problems, but there is no checkbox in "files" so I'm not sure if that's the case.  I used the exact code that's on the forum.  From what I've read it might have to do with the "delayed loading" or _init.php file, but I can't identify the issue.  Any help would be very much appreciated.  The URL is:
 

http://www.roofcoonline.com/rss/

Share this post


Link to post
Share on other sites

Hi @majake and welcome to the PW forums. :)

I haven't used this module before, but I think you're right about the problem being related to a "delayed output" strategy. There is probably a template file being auto-appended to your RSS template - typically this would be called "main.php", "main.inc" or something similar. The instruction to auto-append this template file will be in your site config: probably in the /site/config.php file unless your site is using the ProcessWire Config module that stores additional config settings in separate JSON file.

If there is a template file being auto-appended you should see a checkbox to disable this for the RSS template: Setup > Templates > rss (or whatever your template is called) > Files tab

2016-10-21_141640.png

 

  • Like 1

Share this post


Link to post
Share on other sites

Hi Robin, thanks for the reply, this was my theory, but I do not have the disable automatic append checkbox in the template files tab.  I've also looked at the config file and there are no append lines.  Where else would you look?

Share this post


Link to post
Share on other sites

@majake - I suggest you remove the config info in your previous post for the sake of security. You don't want to be posting your DB username/pass etc in a public forum.

A couple of other ways that "main.php" might be appended:

1. The file is pulled in with an include in your RSS template. Probably not as I expect you would have noticed this.

2. It would be unusual, but I suppose the file could be appended in a hook.

So you could try this:

In your RSS template, insert this:

<?php $no_main = true; ?>

And at the first line of "main.php" (or whatever the file is called that contains your header/footer markup):

<?php if(isset($no_main) && $no_main) return; ?>

 

Edit: actually, could you post the contents of your RSS template file? That will help get to the bottom of the problem.

  • Like 1

Share this post


Link to post
Share on other sites

I'm not actually sure where the header/footer data resides.  I don't have a main.php...

The RSS template file was copied directly from this thread:

 

<?php

// retrieve the RSS module
$rss = $modules->get("MarkupRSS");

// configure the feed. see the actual module file for more optional config options.
$rss->title = "Latest updates";
$rss->description = "The most recent pages updated on my site";

// find the pages you want to appear in the feed.
// this can be any group of pages returned by $pages->find() or $page->children(), etc.
$items = $pages->find("limit=10, sort=-modified");

// send the output of the RSS feed, and you are done
$rss->render($items);

Share this post


Link to post
Share on other sites

@majake

I did a bit of sleuthing and I think your website may be using the Spex module.
http://modules.processwire.com/modules/spex/

I don't think this module is very widely used (it doesn't come up often in the forum) so there may not be many members here who can help you with it. But check out the links above and that may point you in the right direction.

One more thing - your site seems to already have an RSS feed with the same content you are trying to output: http://www.roofcoonline.com/blog/rss

  • Like 2

Share this post


Link to post
Share on other sites

Hi Robin,

Thanks for the info.  I hadn't actually wasn't aware of the existing RSS feed and I'm not sure where it resides.  What I'm really trying to do is syndicate new blog posts to Twitter automatically with a link back to the full post.  On Wordpress I can do this with IFTTT and use the RSS feed as the trigger channel, but the existing RSS feed isn't formatted for syndication and doesn't have an attribution link back to the main post.  Any ideas for a better way to achieve the end goal?

Share this post


Link to post
Share on other sites

Hi Ryan and Team,

I'm using the module "RSS Feed Generator" v1.0.2, in PW 3.0.42.
(I'm going to upgrade when 3.1 comes out.) :-)

I just noticed that my rss feed here:

http://significatojournal.com/rss/

doesn't display anything in Chrome (but works in Firefox).
(The source xml is being generated.)

I also saw that Chrome requires an RSS extension to display RSS:

https://chrome.google.com/webstore/detail/rss-feed-reader/pnjaodmkngahhkoihejjehlcdlnohgmp?hl=en

so I installed it, but still nothing.

I then went to the NY Times and saw that their feed worked in Chrome *if* the extension was installed.

I compared the raw xml at the NY Times against the raw xml in my feed, and saw a significant difference.

However, since the xml is generated by the module, I didn't really want to mess with it.

Here are the two snippets from the headers. (The rss tree looks similar -- it's just the first set of declarations that look different.)

RSS FEED GENERATOR AT SIGNIFICATOJOURNAL.COM:

<?xml version='1.0' encoding='utf-8' ?>
<?xml-stylesheet type='text/xsl' href='/site/templates/styles/rss_feed.xsl' ?>
<rss version='2.0' xmlns:dc='http://purl.org/dc/elements/1.1/'>

NY TIMES FEED:

<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:nyt="http://www.nytimes.com/namespaces/rss/2.0" version="2.0">

I believe that the module should be modified, for Chrome support.

Any thoughts?

Thanks!

Peter

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...