JavaScript Export
JavaScript Export
By Paul
18/10/03 (Edited 29/11/18)
Suppose you want to display top listings from your site on a page which is part of another website, or a non-WSN script. You may either want to do this on one of your own pages, or to distribute the ability to your site's visitors so that they can place your list of top links on their own site. This is possible with WSN's JavaScript export feature.
Customize the look and feel of the exported data at Admin Panel -> Themes -> Manage Templates -> 'JavaScript Export'. Note that if you're doing a toplist of something other than listings you must edit the template to something that includes the template variables of the type you're trying to display.
Next, go to Admin Panel -> Themes -> Toplist Generator. Generate a toplist for the data you're going to want to export. When it gives you the resulting template code to use, find the line that starts with <CONFIG> and ends with </CONFIG>. Copy that line and paste it into the top box at Admin Panel -> Miscellaneous -> JavaScript Export. In the bottom box there, type your desired descriptive filename like 5highestrated.js.
If all your javascript exports are going to use the same template variables, you're done... but if you need some to use different template variables, then you'll need to set up custom templates. Start by creating an empty custom template, then copy the content of the 'JavaScript Export' template into it. Replace the body of the toplist with the new one you want (important note: never change the toplist number, it must stay #1) and save your changes. Finally, at Admin -> Miscellaneous -> JavaScript Export place your custom template name and a | character before the <CONFIG> line in the top box.
Place <script language="javascript" src="http://yourwsnlocation/javascript/5highestrated.js"> </script> in the page where you want the generated yourname.js content shown. Change yourwsnlocation to where you've installed WSN, and 5highestrated.js to the name you chose on the javascript export page. The content will be cached to ensure it doesn't create a high load on your site, and is refreshed automatically every 12 hours.</span></p>
For Advanced Users
If you really want instant data with total flexibility, you can use this basic JavaScript:
<script language="javascript" src="http://yourwsnlocation/exporter.php"></script>
Change yourwsnlocation to where you've installed WSN. You can add parameters onto the end by adding ?name=value. Set the default by editing the template. The available parameters are the same as for any toplist:
type[1]
number[1]
field[1]
order[1]
ascdesc[1]
thecondition[1]
Example: For a JavaScript to show a toplist of the 10 newest comments, use <script language="javascript" src="http://yoursite.com/wsnlinks/exporter.php?number[1]=10&field[1]=time&ascdesc[1]=descending&type[1]=comments&custom=yes&TID=commentexport"></script>. Note this calls a commentexport custom template which you've created with your desired comment template variables as we covered earlier. If you leave off &custom=yes&TID=commentexport then the regular javascript export template will be used.
To do only regular type comments, you'd use <script language="javascript" src="http://yoursite.com/wsnlinks/exporter.php?number[1]=10&field[1]=time&ascdesc[1]=descending&type[1]=comments&thecondition=type='regular'&custom=yes&TID=commentexport"></script>
If you're using this to let other people put your content on their site, you can either instruct them in how to customize it or write up specialized versions for them... however, this is not advised due to the slowness involved. This exporter.php call method is dynamic, and thus slow. The page has to be generated on the server before being sent as javascript.
By Paul
18/10/03 (Edited 29/11/18)
Customize the look and feel of the exported data at Admin Panel -> Themes -> Manage Templates -> 'JavaScript Export'. Note that if you're doing a toplist of something other than listings you must edit the template to something that includes the template variables of the type you're trying to display.
Next, go to Admin Panel -> Themes -> Toplist Generator. Generate a toplist for the data you're going to want to export. When it gives you the resulting template code to use, find the line that starts with <CONFIG> and ends with </CONFIG>. Copy that line and paste it into the top box at Admin Panel -> Miscellaneous -> JavaScript Export. In the bottom box there, type your desired descriptive filename like 5highestrated.js.
If all your javascript exports are going to use the same template variables, you're done... but if you need some to use different template variables, then you'll need to set up custom templates. Start by creating an empty custom template, then copy the content of the 'JavaScript Export' template into it. Replace the body of the toplist with the new one you want (important note: never change the toplist number, it must stay #1) and save your changes. Finally, at Admin -> Miscellaneous -> JavaScript Export place your custom template name and a | character before the <CONFIG> line in the top box.
Place <script language="javascript" src="http://yourwsnlocation/javascript/5highestrated.js"> </script> in the page where you want the generated yourname.js content shown. Change yourwsnlocation to where you've installed WSN, and 5highestrated.js to the name you chose on the javascript export page. The content will be cached to ensure it doesn't create a high load on your site, and is refreshed automatically every 12 hours.</span></p>
For Advanced Users
If you really want instant data with total flexibility, you can use this basic JavaScript:
<script language="javascript" src="http://yourwsnlocation/exporter.php"></script>
Change yourwsnlocation to where you've installed WSN. You can add parameters onto the end by adding ?name=value. Set the default by editing the template. The available parameters are the same as for any toplist:
type[1]
number[1]
field[1]
order[1]
ascdesc[1]
thecondition[1]
Example: For a JavaScript to show a toplist of the 10 newest comments, use <script language="javascript" src="http://yoursite.com/wsnlinks/exporter.php?number[1]=10&field[1]=time&ascdesc[1]=descending&type[1]=comments&custom=yes&TID=commentexport"></script>. Note this calls a commentexport custom template which you've created with your desired comment template variables as we covered earlier. If you leave off &custom=yes&TID=commentexport then the regular javascript export template will be used.
To do only regular type comments, you'd use <script language="javascript" src="http://yoursite.com/wsnlinks/exporter.php?number[1]=10&field[1]=time&ascdesc[1]=descending&type[1]=comments&thecondition=type='regular'&custom=yes&TID=commentexport"></script>
If you're using this to let other people put your content on their site, you can either instruct them in how to customize it or write up specialized versions for them... however, this is not advised due to the slowness involved. This exporter.php call method is dynamic, and thus slow. The page has to be generated on the server before being sent as javascript.
Description | Using WSN information on static pages and other websites. |
Rating | |
Views | 2962 views. Averaging 0 views per day. |
Similar Listings |