Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Offset not working #114

Open
queenofrandom opened this issue Aug 9, 2016 · 11 comments
Open

Offset not working #114

queenofrandom opened this issue Aug 9, 2016 · 11 comments

Comments

@queenofrandom
Copy link

queenofrandom commented Aug 9, 2016

When I use the offset feature the RSS disappears entirely and the div is completely empty. My feed is http://news.bearingnet.net/feed/

Code

jQuery(function($) { $("#rss-feeds").rss("http://news.bearingnet.net/feed/", { offsetStart: 2, offsetEnd: 8, layoutTemplate: "<div class='feed-container'>{entries}</div>", entryTemplate: "<div class='rssEntry'><p class='padding-top'>{teaserImage}<a href='{url}' target='_blank'>{title}</a><br /> {date} <br />{shortBodyPlain}...<div class='text-right'></p><p><a href='{url}' target='_blank' class='btn main-bg'>Read more</a></p></div></div>", }) })

If i remove offsetEnd the feed reappears but doesn't seem to apply an offset


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@queenofrandom
Copy link
Author

Anything please?

@meancode
Copy link

I am also having an issue with offsetStart working. Using offsetStart: 0 and offsetStart: 4 makes no difference. @sdepold please help!

@myrises
Copy link

myrises commented Dec 23, 2016

need fix code in line 131 to
$(this.entries).each(function (index) {

@uudruid74
Copy link

Also having this issue. Actually, its not entirely an "offset" that I want, but rather a way to fetch a small number of entries and expand this as the user scrolls down. The jQuery to implement this is pretty trivial if the offset feature was working, but it would be even better if there was a simple "fetch next XXX entries and add to container" type of call we could make where it appended to the container and kept track of it's own offset. I think this would be common enough to add to the library.

@kukoss
Copy link

kukoss commented Jan 18, 2018

HI guys, has anythying been done on this? the offset is very trivial error :(

@kukoss
Copy link

kukoss commented Jan 18, 2018

guys, I fixed it. Basically there is an index element missing in each function. Replace function generateHTMLForEntries, do this:

and dont forget, offsetStart and offsetEnd have to be both numbers at the same time. this was done originally so I didn't change that logic.

` RSS.prototype.generateHTMLForEntries = function () {
var self = this;
var result = { entries: [], layout: null };
$(this.entries).each(function (index, elem) {
var entry = this;
var offsetStart = self.options.offsetStart;
var offsetEnd = self.options.offsetEnd;
var evaluatedString;
// offset required
if (offsetStart >= 0 && offsetEnd >= 0) {
if (index >= offsetStart && index <= offsetEnd) {
if (self.isRelevant(entry, result.entries)) {
evaluatedString = self.evaluateStringForEntry(
self.options.entryTemplate, entry
);

        result.entries.push(evaluatedString);
      }
    }
  } else {
    // no offset
    if (self.isRelevant(entry, result.entries)) {
      evaluatedString = self.evaluateStringForEntry(
        self.options.entryTemplate, entry
      );

      result.entries.push(evaluatedString);
    }
  }
});

if (!!this.options.entryTemplate) {
  // we have an entryTemplate
  result.layout = this.wrapContent(
    this.options.layoutTemplate.replace('{entries}', '<entries></entries>')
  );
} else {
  // no entryTemplate available
  result.layout = this.wrapContent('<div><entries></entries></div>');
}

return result;

};`

@sdepold
Copy link
Owner

sdepold commented Jan 18, 2018 via email

@kukoss
Copy link

kukoss commented Jan 18, 2018

@sdepold what is pr? :)

@sdepold
Copy link
Owner

sdepold commented Jan 18, 2018

A Pull Request :) This way you can provide changes to my code base :)

@uudruid74
Copy link

@kukoss PR = Pull Request. You have to fork the repository on github to your own, apply the changes you made to your fork, then you'll see a button to send a "pull request" to the original author. This allows the changes to be cleanly tracked, merged, and applied in a nice automated fashion.

@kukoss
Copy link

kukoss commented Jan 18, 2018

thanks guys. done....at least I hope so, I've done it correctly :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants