[For 1.8] Generate Syndication URL on the fly
For those lazy heads: let's save a click!

To generate a new syndication URL you need to click on the "Generate Syndication URL" button after choosing your desired forums, syndication version and limit. This will generate the URL on the fly in front of your eyes as you change your preference. Lets do it.

Open the template misc_syndication and find the variable {$feedurl}. Add the following script before that: 
Note: You need to add the script before the var, not after, else jQuery will be confused to identify the element holding URL.
<script>$(function(){var i=parseInt($("input[name=limit]").val(),10),t=[];$("input[type=submit]").hide(),$(":contains(syndication.php):last").attr("id","feedurl"),$("select[name='forums[]'], input[name='version'], input[name=limit]").on("change keyup",function(){t.fid=$("select[name='forums[]']").val(),t.fid=0===t.fid.length||0===$.inArray("all",t.fid)?"":"fid="+t.fid.join(","),t.ver=$("input[name='version']:checked").val(),t.ver=""===t.ver||"rss2.0"===t.ver?"":"type="+t.ver,t.lmt=$("input[name=limit]").val(),t.lmt="limit="+(isNaN(t.lmt)||t.lmt<1?i:t.lmt),t=[t.fid,t.ver,t.lmt].filter(function(i){return""!==i}),$("#feedurl").text(rootpath+"/syndication.php?"+t.join("&"))})});</script>

Thats all.

This will hide the "Generate Syndication URL" button, but don't worry, wee don't need that anymore.

Now save the template. Done.

[Image: screen.gif]

For the readability of the curious minds, this is the expanded version of the script (which you can also use in place of the above):
<script type="text/javascript">
var rootLimit = parseInt($("input[name=limit]").val(), 10), param = [];
$(":contains(syndication.php):last").attr('id', 'feedurl');
$("select[name='forums[]'], input[name='version'], input[name='limit']").on('change keyup', function(){
param.fid = $("select[name='forums[]']").val();
param.fid = (param.fid.length === 0 || $.inArray("all", param.fid) === 0) ? "" : "fid="+param.fid.join(",");
param.ver = $("input[name='version']:checked").val();
param.ver = (param.ver === "" || param.ver === "rss2.0") ? "" : "type="+param.ver;
param.lmt = $("input[name=limit]").val();
param.lmt = "limit=" + ((isNaN(param.lmt) || param.lmt < 1) ? rootLimit : param.lmt);
param = [param.fid,param.ver,param.lmt].filter(function(v){return v!==''});
$("#feedurl").text(rootpath + "/syndication.php?" + param.join("&"));
Thank you for your contribution Smile
Pretty good Wink
Great, thx!
[MyBB 1.8 Czech translation] [MyBB 1.8 plugins]: Prune old PMs + optimize DB plugin --- Thank you/like system

Forum Jump:

Users browsing this thread: 1 Guest(s)