WSN Gallery https://scripts.webmastersite.net/wsngallery/manual en-us Allowing End Users to Change Toplists Make selectors to let users choose what to see. https://scripts.webmastersite.net/wsngallery/manual/templates-and-styles/templates/toplists/allowing-end-users-to-change-toplists-504.html Tue, 14 Jul 2009 23:45:18 GMT https://scripts.webmastersite.net/wsngallery/manual/templates-and-styles/templates/toplists/allowing-end-users-to-change-toplists-504.html
<form action="index.php" style="margin: 0px; padding: 0px;">
<div class="box">
<div class="boxtitle" onclick="minmax('topbox')"><img src="{IMAGESURL}/icon_show.gif" > Top {TOPLISTTOTAL1} Links</div>
<div class="boxbody" id="topbox">
Show
<select name="number[1]">
<option value="5">5</option>
<option value="10">10</option>
<option value="15">15</option>
</select>
<select name="thefield[1]">
<option value="time">newest</option>
<option value="rating">top rated</option>
<option value="hits">most visited</option>
</select>
<input type="submit" value="Go" class="button" >
<br >
<!-- BEGIN TOPLIST 1 -->
<CONFIG>links[,]time[,]5[,]descending</CONFIG>
{NUMBER}. <a href="{TRACKLINKURL}" class="newlinks" {EXTERNALLINKS}>{LINKTITLE}</a> {LINKADMIN}
<br >
<!-- END TOPLIST 1 -->
</div>
</div>
</form>


To add an alphabetical option, add
<option value="title">alphabetically</option>
in the number[1] selector... and so on for all other fields in the applicable mysql table.

To do allow ascending/descending selection add
<select name="order[1]">
<option value="asc">ascending</option>
<option value="desc">descending</option>
</select>
]]>
Cross-Script Toplists Making a toplist of items from one WSN script while in another. https://scripts.webmastersite.net/wsngallery/manual/templates-and-styles/templates/toplists/cross-script-toplists-294.html Mon, 20 Jun 2005 09:35:14 GMT https://scripts.webmastersite.net/wsngallery/manual/templates-and-styles/templates/toplists/cross-script-toplists-294.html Presuming you own multiple WSN scripts, sometimes you may wish to show toplists of items from a different WSN script than the one you're in. The toplist syntax remains the same as usual for the most part, with the first term changing to indicate the desired database table. It's easiest to explain this by example. Here's a toplist that will show the five newest images from WSN Gallery within any of the other scripts:
<!-- BEGIN TOPLIST -->
<CONFIG>wsngallery_links[,]id[,]5[,]descending</CONFIG>
<a href="
{LINKDETAILSURL}">{LINKTHUMBIMAGE}</a>
<!-- END TOPLIST -->

sngallery_links is simply the name of the database table you want the data from, which you can find in phpmyadmin. For another example, here's a way to show the most recently posted in ten threads from WSN Forum within WSN Links (or Gallery or KB):
<!-- BEGIN TOPLIST -->
<CONFIG>wsnforum_links[,]lastcomment[,]10[,]descending</CONFIG>
<a href="
{LINKTHREADURL}">{LINKTITLE}</a> by {LINKOWNERNAME}<br>
{LINKMESSAGE[50]}<br>
<!-- END TOPLIST -->


Finally, you can show similar threads from your forum within WSN Links (or vice versa, or any other combination) with a special toplist condition like this:
<!-- BEGIN TOPLIST -->
<CONFIG>wsnforum_links[,]time[,]5[,]descending[,]MATCH (title) AGAINST('{LINKTITLE}')</CONFIG>
<a href="{LINKTHREADURL}">{LINKTITLE}</a><br>
<!-- END TOPLIST -->

You can do cross-script toplists for comments, categories/forums, etc as well just by using the appropriate table name.

Troubleshooting

Important note: when doing URL rewriting, you must have the same rewrite formatting (except for template variables being of the host script's type of course) on all the scripts involved for it to rewrite correctly in cross-script toplists. You can work around this by writing out non-rewritten versions of the URLs, if you need to.

]]>
Totals and Pagination Multipage toplists. https://scripts.webmastersite.net/wsngallery/manual/templates-and-styles/templates/toplists/totals-and-pagination-204.html Thu, 15 Jul 2004 18:14:36 GMT https://scripts.webmastersite.net/wsngallery/manual/templates-and-styles/templates/toplists/totals-and-pagination-204.html
To paginate a toplist, simply select in the toplist generator to use pagination (Admin -> Themes -> Toplist Generator) or use {TOPLIST1PAGINATION} where 1 is the toplist number. See here for more details of the pagination system.

If your toplist doesn't yet have a number, you'll need to go into the template and add a number, like this: <!-- BEGIN TOPLIST 1 --> <!-- END TOPLIST 1 -->]]>
Advanced Toplist Tasks Exploring some of the more complicated possibilities of toplists. https://scripts.webmastersite.net/wsngallery/manual/templates-and-styles/templates/toplists/advanced-toplist-tasks-158.html Thu, 11 Mar 2004 04:50:08 GMT https://scripts.webmastersite.net/wsngallery/manual/templates-and-styles/templates/toplists/advanced-toplist-tasks-158.html Construct your toplist using the toplist generator at Admin Panel -> Themes -> Toplist Generator. In a toplist, the 'filtering condition' option is the most powerful and diffcult part. This allows you to select which listings, categories, comments or members you need to show. The condition uses MySQL syntax, and this allows many options. (For those who know MySQL: the condition is placed after "WHERE" in the MySQL SELECT query.)

Filtering by Date Range

Suppose you need to show all listings from between two particular dates. There isn't any 'date' field in the database... the 'time' field is in the form of a Unix timestamp (the number of seconds since 1970). So instead you need to take advantage of MySQL's integrated functions. This filtering condition would grab everything from October 4th through 6th of 1997:

time > UNIX_TIMESTAMP('1997-10-04 00:00:00') AND time < UNIX_TIMESTAMP('1997-10-07 00:00:00')

There are many other MySQL functions listed in the MySQL manual at http://www.mysql.com/doc/en/ . Date and time functions are at http://www.mysql.com/doc/en/Date_and_time_functions.html

To get the current time, use UNIX_TIMESTAMP() with no arguments passed. Thus to get all listings from the last 10 days, your condition would be

time > (UNIX_TIMESTAMP() - 60*60*24*10)

The last portion of this is simply the number of seconds which exist in 10 days: 60 seconds per minute times 60 minutes per hour times 24 hours per day times 10 days.

Filtering by Top Level Category

Another task: Suppose you want to make a toplist of all listings in category #1 and all its subcategories. Just the category alone is easy enough by supplying a condition catid=1. Including listings from subcategories of 1 takes a more complicated condition: catid=1 OR parentids LIKE '%|1|%'. This means where the category is 1 or one of the category's parents is 1.

You can compare with any field from the database. Feel free to ask WSN support for help on making your filtering condition.

]]>
Introduction to Toplists Tips on proper use of this powerful feature. https://scripts.webmastersite.net/wsngallery/manual/templates-and-styles/templates/toplists/introduction-to-toplists-15.html Thu, 25 Sep 2003 14:34:02 GMT https://scripts.webmastersite.net/wsngallery/manual/templates-and-styles/templates/toplists/introduction-to-toplists-15.html Toplists are lists of data from your site, ordered and formatted in the manner of your choosing. For example, you could make a list of the 5 most recent listings or the 10 top rated listings, or the 8 most recent comments on listing #14 that have at least one upvote. Your admin panel includes a toplist generator to help you make toplists. Go to Admin Panel -> Themes -> Toplist Gernerator and answer its questions.

Toplists can be used in any template (Admin -> Themes -> Manage Templates), and also in all emails. They can be especially useful in the bulk emails which you send from the Admin Panel -> E-mails -> Send E-mails page, if for example you want to send a newsletter that automatically lists the most recent new listings.

Even though the toplist generator makes the code for you, you may wish to understand in more depth how the feature works. Here's an example:

<!-- BEGIN TOPLIST 1 -->
<CONFIG>links[,]id[,]5[,]ascending[,]votes>5[,]0[,]0[,]1</CONFIG>
content
<!-- END TOPLIST 1 -->


The example config line for toplist 1 above makes a toplist of links ordered by their rating, showing 10 links in descending order, excluding any links which have less than 5 votes, not skipping past any of these defined results, and not showing unvalidated items. You don't need to understand the CONFIG line though, just use the toplist generator.

If you want more than one toplist on the same page, they must all use unique numbers. For example the 2nd one could use the number 2 in the beginning and end declaration... and the third could use 3, et cetera. If they're on different pages this doesn't matter and you can just use 1. Please note that the wrapper is considered to be a part of every page.

Note the power of the filtering condition option. With it you can filter to only the toplist of links owned by a particular member, for example, using the condition ownerid={MEMBERID}. You could also show top links for only a particular category, using catid={CATID}.

If you want a numbered list (for example, a top 10), use {NUMBER} where you want the number displayed.

Be careful to check after changing a toplist to be sure it worked. If you make a little mistake, you'll end up with errors on the page... thus, always be prepared to change it back and don't assume that you couldn't have made a typo. Of course it won't cause any problems that can't be fixed by simply changing/removing the toplist, but it's not good for visitors to see such errors.

Advanced Tricks

You can dyamically alter a toplist by supplying terms in the url of the page or in a form post. For a toplist numbered 1, you could use &field[1]=votes to change the field we are ordering by to be votes regardless of what is specified in the config line in the template. Options: type[1], thefield[1], number[1], order[1], thecondition[1], thestart[1], thecolumns[1], theunval[1], thehidden[1], thealbums[1]. (On the 'edit' pages, to avoid a conflict you need to use thefield[1] instead.)

]]>