this is for you if
But, i already have some codes assuming i can specify my max-results value to be anything. But no! Even if you set max-results=2000, the feed output will stop at 500.
Meanwhile if you do not set any value for max-result, it's set at 25 by default.
So, in case you already wrote codes like me, this simple fix will help you out without having to alter those codes. If you have not, you can learn here.
Also remove all variable definitions of entry. That is,
Good Luck!
- you use blogger
- you use blogger atom feed output for coding, either json or json-in-script
- you probably have had codes (with javascript) assuming blogger atom maximum output is unlimited
http://www.lyricsbible.net/atom.xml?redirect=false&start-index=1&max-results=500
http://www.lyricsbible.net/atom.xml?redirect=false&start-index=501&max-results=500
But, i already have some codes assuming i can specify my max-results value to be anything. But no! Even if you set max-results=2000, the feed output will stop at 500.
Meanwhile if you do not set any value for max-result, it's set at 25 by default.
So, in case you already wrote codes like me, this simple fix will help you out without having to alter those codes. If you have not, you can learn here.
- Go To Edit Templates, and click Edit HTML. {you see templatehtml}
- First to a backup of your code, just in case something goes wrong, so you can restore the previous codes. Copy all the HTML into a text editor.
- Now place the following code just before the </head>
Trace all the codes where you have written something like this: json.feed.entry or input.feed.entry or something-something.feed.entry. Remove the 'something-something' or 'json' or 'input' part, and also the '.feed.'<script type='text/javascript'>
//<![CDATA[
var entry=[], setJsonCount=0; //set as global
function setJson(input){//populate the feeds once and for all as global
setJsonCount++;
try{entry = entry.concat(input.feed.entry);
if(input.feed.entry.length==500){
var factor = setJsonCount*500 + 1 //e.g. 1*500+1=501, 2*500+1=1001 etc
var str = '<script src="/feeds/posts/default?max-results=500&start-index='+factor+'&alt=json-in-script&callback=setJson"><\/script>';
document.write(str)
}//end if
}catch(e){}
}
//]]>
</script>
<script src='/feeds/posts/default?max-results=2000&alt=json-in-script&callback=setJson'/>
Also remove all variable definitions of entry. That is,
var entry = ...Now your code should cope with over 500 posts without crashing.
Good Luck!
No comments:
Post a Comment