RSS

Permalink
Is there any way of including images in my automatically generated page list feeds, for example here:

http://mattgreydesign.com/index.php/tools/blocks/page_list/rss?bID=...

And is there any way of cleaning up that messy URL as well (without buying the block)?

MattGreyDesign
 
jordanlev replied on at Permalink Reply
jordanlev
Are you a programmer? If so, I can give you some guidance about showing images in the RSS feed, and maybe cleaning up the messy URL (but if you're not a programmer it's going to be too difficult for me to explain -- sorry).
MattGreyDesign replied on at Permalink Reply
MattGreyDesign
I can do some things if I have the elements or a good idea, I set up my site, made my own templates for the site and page-list block etc. that should be enough knowledge shouldnt it?
jordanlev replied on at Permalink Reply
jordanlev
No harm in trying...

So there's a free addon in the marketplace that does the "images in page list" thing:

http://www.concrete5.org/marketplace/addons/thumbview-template/...

But it doesn't alter the RSS feed. To do that, you need to override the rss.php tools file for the page_list block.

Create a new folder in your site: YOURSITE/blocks/page_list/tools/

Now copy the file YOURSITE/concrete/blocks/page_list/tools/rss.php to that new folder you created (so the new copy is YOURSITE/blocks/page_list/tools/rss.php -- NOT in the "concrete" directory).

Edit that new copy, find this line:
<description><?php echo htmlspecialchars(strip_tags($cobj->getCollectionDescription()))."....";?></description>


And change it to this:
<description><?php
  echo '<![CDATA[';
  echo htmlspecialchars(strip_tags($cobj->getCollectionDescription()))."....";
  $imgHelper = Loader::Helper('image');
  $img = $cobj->getCollectionAttributeValue('page_thumbnail');
  echo $img ? $imgHelper->outputThumbnail($img, 190, 190, '') : '';
  echo ']]>';
?></description>


Now the image will appear after the description in the rss feed.

As for the "pretty URL" for the RSS feed, well I don't think there's an elegant way to do this, but you can hack it by getting the "ugly" url, adding a rewrite rule in your .htaccess file to map a pretty url to that ugly url. Then, edit the custom template for your page_list (if you used the addon from above, it's either in:
YOURSITE/packages/thumbview_template/blocks/page_list/templates/thumbview/view.php
OR:
YOURSITE/packages/thumbview_template/blocks/page_list/templates/thumbview2/view.php
(depending on which custom template you chose for the page list).
In that custom template view.php file, find this line:
$rssUrl = $controller->getRssUrl($b);

and change it to this:
$rssUrl = 'http://yoursite.com/yourprettyurl'; //Change this to the pretty url you set in the .htaccess file


This should work, but beware that it is *very* brittle, and will fail if you edit that page list block, or move it, or put it on another page (or if you create another page_list on another page with an RSS feed, it will wind up using this one's pretty url and hence go to the wrong feed).

You could get more advanced with it and check which page you're on to make sure that's the correct RSS URL you're outputting -- depends on how much it's worth the trouble.

Good luck!
MattGreyDesign replied on at Permalink Reply
MattGreyDesign
Right, i gave it a try and it doesnt show up with the images, just boxes where there should behttp://mattgreydesign.com/index.php/tools/blocks/page_list/rss?bID=...
jordanlev replied on at Permalink Reply
jordanlev
Hmm... when I click that link I get the normal RSS feed, without placeholder boxes for images (and I checked the source and don't see the new code in there), so I'm guessing it didn't get picked up somehow.
Not sure what to tell you -- it's going to require some troubleshooting on your part (sorry it's not possible to solve everything over the forums, there are so many little details and things that might be configured a certain way on different sites). Maybe walk through the steps again and make sure you didn't miss anything? Try just putting some text into that new rss.php and see if that comes up in the feed. If not, then make sure you have that file in the proper folder. If so, then make sure you actually assigned images to the page_thumbnail attributes (as instructed by that addon I linked to).
MattGreyDesign replied on at Permalink Reply
MattGreyDesign
sorry I took it off temporarily because it was messy, ill put it back on.

- Right...

I haven't used the addon you reccomended, instead I'm using the attribute from my custom pagelist that I made already made(http://mattgreydesign.com/projects/)

The PHP that I used was:
<?php echo $imgHelper->getThumbnail($cobj->getAttribute('thumbnail'), 540, 225)->src ?>


So I just changed your code to that attribute
jordanlev replied on at Permalink Reply
jordanlev
Looks like it's working now -- is it working for you too? If so, nice job! If not, what are you using to view the RSS feed (I just clicked on the feed link in Firefox and the images showed up with the descriptions -- haven't tried it in google reader or anything).
MattGreyDesign replied on at Permalink Reply
MattGreyDesign
Yes I think its what I'm viewing it in now, hmm, not in the format I would like though
MattGreyDesign replied on at Permalink Reply
MattGreyDesign
I would, however, like to reorder it so that the image is first, followed by the description on a different line and then a link saying "Read More"
something like this: (but it didn't work)

echo '<![CDATA[';  
   $imgHelper = Loader::Helper('image');
   $img = $cobj->getCollectionAttributeValue('thumbnail');
   echo $img ? $imgHelper->outputThumbnail($img, 190, 400, '') : '';
   echo htmlspecialchars(strip_tags($cobj->getCollectionDescription()))."...";
   echo "<a href="&quot; BASE_URL.DIR_REL.$nh->getLinkToCollection($cobj)"&quot; alt=&quot;Read More&quot;> Read More</a>";
   echo ']]>';
jordanlev replied on at Permalink Reply
jordanlev
When I look at your feed, there's a closing ">" right after the "<![CDATA[" thing -- there may be a typo in your code somewhere. Also, it's hard to tell from the sample code you posted but it looks like your a href code has weird quotes in it.
MattGreyDesign replied on at Permalink Reply
MattGreyDesign
I thought you had to echo the quote html code, thats all, im sure its wrong to put
echo "<a href="BASE_URL.DIR_REL.$nh->getLinkToCollection($cobj) alt="Read More"> Read More</a>";
jordanlev replied on at Permalink Reply
jordanlev
Yeah, so I'm still not seeing the "a href" in your feed. And also I still do see the extra ">" following the CDATA thing. Also also, I'm not sure if this is a problem in the way you're pasting the code into the forum here or if it's your actual code, but you want that line to be this:
echo '<a href="' . BASE_URL . DIR_REL . $nh->getLinkToCollection($cobj) . '" alt="Read More">Read More</a>';
MattGreyDesign replied on at Permalink Reply
MattGreyDesign
Do i need to put CDATA in it anyway, what is it? I tried this and its still not working, i realised what i did wrong with the quotes
<description><?php
  echo '<![CDATA[';
  $imgHelper = Loader::Helper('image');
  $img = $cobj->getCollectionAttributeValue('thumbnail');
  echo $img ? $imgHelper->outputThumbnail($img, 860, 300, '') : '';
  echo htmlspecialchars(strip_tags($cobj->getCollectionDescription()))."....";
  echo '<a href="'echo  BASE_URL.DIR_REL.$nh->getLinkToCollection($cobj)'" alt="Read More">Read More</a>';
  echo ']]>';
?></description>
jordanlev replied on at Permalink Reply
jordanlev
You need the CDATA thing otherwise the RSS feed won't work -- it will mistake the html that's part of your content (like the image tag and the link) as part of the XML of the RSS feed itself.
So whatever you want in that description needs to start with "<![CDATA[" and end with "]]>" (no quotes).
For example:
<![CDATA[all of my content goes here, including html tags like this <img src="http://example.com/pic.jph" />.]]>
MattGreyDesign replied on at Permalink Reply
MattGreyDesign
Oh ok then. I just need to get it to echo the url again in read more
echo  BASE_URL.DIR_REL.$nh->getLinkToCollection($cobj

I cant get it to work!