Generate Syndication URL on the fly

Spartak

Well-known member
Member
Joined
9 yrs. 9 mth. 5 days
Messages
587
Reaction score
8,878
Wallet
0$
Generate Syndication URL on the fly

For those lazy heads: let's save a click!<br />
<br />
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.<br />
<br />
Open the template <code class="inline-code">misc_syndication</code> and find the variable <code class="inline-code">{$feedurl}</code>. Add the following script <span style="text-decoration: underline;" class="mycode_u">before</span> that: <br />
<span style="font-style: italic;" class="mycode_i">Note: You need to add the script before the var, not after, else jQuery will be confused to identify the element holding URL.</span><br />
<pre data-deferred="true" class="block-code line-numbers language-none"><code class="language-none">&lt;script&gt;$(function(){var i=parseInt($(&quot;input[name=limit]&quot;).val(),10),t=[];$(&quot;input[type=submit]&quot;).hide(),$(&quot;:contains(syndication.php):last&quot;).attr(&quot;id&quot;,&quot;feedurl&quot;),$(&quot;select[name='forums[]'], input[name='version'], input[name=limit]&quot;).on(&quot;change keyup&quot;,function(){t.fid=$(&quot;select[name='forums[]']&quot;).val(),t.fid=0===t.fid.length||0===$.inArray(&quot;all&quot;,t.fid)?&quot;&quot;:&quot;fid=&quot;+t.fid.join(&quot;,&quot;),t.ver=$(&quot;input[name='version']:checked&quot;).val(),t.ver=&quot;&quot;===t.ver||&quot;rss2.0&quot;===t.ver?&quot;&quot;:&quot;type=&quot;+t.ver,t.lmt=$(&quot;input[name=limit]&quot;).val(),t.lmt=&quot;limit=&quot;+(isNaN(t.lmt)||t.lmt&lt;1?i:t.lmt),t=[t.fid,t.ver,t.lmt].filter(function(i){return&quot;&quot;!==i}),$(&quot;#feedurl&quot;).text(rootpath+&quot;/syndication.php?&quot;+t.join(&quot;&amp;&quot;))})});&lt;/script&gt;
</code></pre><br />
Thats all.<br />
<br />
This will hide the "Generate Syndication URL" button, but don't worry, wee don't need that anymore.<br />
<br />
Now save the template. Done.<br />
<br />
Result:<br />
<img src="
Please, Log in or Register to view URLs content!
" data-original-url="https://s7.gifyu.com/images/screen.gif" loading="lazy" alt="[Image: screen.gif]" class="mycode_img" /><br />
<br />
tl;dr:<br />
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):<pre data-deferred="true" class="block-code line-numbers language-none"><code class="language-none">&lt;script type=&quot;text/javascript&quot;&gt;
$(function(){
var rootLimit = parseInt($(&quot;input[name=limit]&quot;).val(), 10), param = [];
$(&quot;input[type=submit]&quot;).hide();
$(&quot;:contains(syndication.php):last&quot;).attr('id', 'feedurl');
$(&quot;select[name='forums[]'], input[name='version'], input[name='limit']&quot;).on('change keyup', function(){
param.fid = $(&quot;select[name='forums[]']&quot;).val();
param.fid = (param.fid.length === 0 || $.inArray(&quot;all&quot;, param.fid) === 0) ? &quot;&quot; : &quot;fid=&quot;+param.fid.join(&quot;,&quot;);
param.ver = $(&quot;input[name='version']:checked&quot;).val();
param.ver = (param.ver === &quot;&quot; || param.ver === &quot;rss2.0&quot;) ? &quot;&quot; : &quot;type=&quot;+param.ver;
param.lmt = $(&quot;input[name=limit]&quot;).val();
param.lmt = &quot;limit=&quot; + ((isNaN(param.lmt) || param.lmt &lt; 1) ? rootLimit : param.lmt);
param = [param.fid,param.ver,param.lmt].filter(function(v){return v!==''});
$(&quot;#feedurl&quot;).text(rootpath + &quot;/syndication.php?&quot; + param.join(&quot;&amp;&quot;));
});
});
&lt;/script&gt;
</code></pre>


Please, Log in or Register to view URLs content!
 
Top Bottom