PDA

View Full Version : gfeedfetcher tweak



agoulet
11-17-2011, 08:46 PM
1) Script Title: gfeedfetcher

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex18/gajaxrssdisplayer.htm

3) Describe problem:

I'm trying to modify the gfeedfetcher script so that it identifies the final rss entry to be displayed and adjusts the class of that div accordingly.

EX:
In the page, I have this set:
newsfeed.setentrycontainer("div class=home-feed-box-events")

So all entries display within <div class="home-feed-box-events">ENTRY</div>

What I would like is for the script to identify the last entry and make that div only look like this: <div class="home-feed-box-events last">ENTRY</div>

Any help would be super appreciated. I have been running into a wall trying to make this work all day.

ddadmin
11-18-2011, 10:35 AM
Ok, try the below modified gfeedfetcher.js file. It modifies the setentrycontainer() method so you can specify a default list of classes to add to all RSS entries, plus another parameter to specify the classes to add on top of that to the very last entry. So something like:


cssfeed.setentrycontainer("div", "home-feed-box-events", "final")

Note that the first parameter should only be used to specify the container tag, and nothing else.

agoulet
11-18-2011, 03:21 PM
You are a life saver! Thanks!

(officially a life-long fan of DD forums!)

agoulet
11-18-2011, 03:39 PM
Another question:

The RSS feed we are pulling from contains an image in the description of each entry. These images are surrounded by a classed div tag. When gfeedreader grabs the description field, it leaves the div tags but strips out the div class.

Ex: in the rss feed we have <div class="rssimg"><img src="..."></div> which gfeedreader outputs as <div ><img src="..."></div>

Is there anyway to prevent that from happening? I would like to keep that div class in place.

Thanks again!

agoulet
11-18-2011, 04:34 PM
Actually a little digging tells me that it is the Google Feed API that strips out the classes / ids from the original rss. One possible solution I saw was to load the feed entries as xml instead of json. Any help on how I would go about doing this?

ddadmin
11-19-2011, 02:12 PM
Hmm while it's certainly possible to modify the script to load the feed in XML format, the changes to the script required to get this to work would be rather intensive. Is the tag that's being stripped out always simply "<div class="rssimg">", or does it change depending on the news item? If the later the script can simply be modified to hard code the lost tag into its output for each of the news entries.

agoulet
11-20-2011, 03:37 PM
After I posted that, I realized it would be a major overhaul of the script. And with a bit more research I am seeing that it probably wouldn't end up working anyway (google would still strip out the tags).

Basically what is happening is that in our rss feed, as I mentioned, we have images linked into the description field. I am able to hardcode a div class into your script that surrounds the entire description field (image and text). What I was trying to do was setup our rss feed to output something like:

<div class="rss-img"<img ...></div><div class="rss-desc">Lorem ipsum...</div>

for the description of each rss entry. That way I could style each part individually and in some cases hide the text entirely if necessary. Unfortunately, google strips out the class or id tags from any divs coded into the rss feed. Strangely enough, google does not strip out inline styles, but that doesn't help me.

I figured out a couple work arounds though, so I should be good to go. They aren't the most ideal, but they work so I'm happy.

Thanks again for all your help!