WSN Classifieds https://scripts.webmastersite.net/wsnclassifieds/manual en-us Multi-Column Field Layout for Listing Details Page Normally, the listing details page shows all the fields and their values in a table with the labels on the left and the values on the right. https://scripts.webmastersite.net/wsnclassifieds/manual/extending/individual-hacks/multi-column-field-layout-for-listing-details-page-640.html Sat, 11 Oct 2014 08:34:40 GMT https://scripts.webmastersite.net/wsnclassifieds/manual/extending/individual-hacks/multi-column-field-layout-for-listing-details-page-640.html Normally, the listing details page shows all the fields and their values in a table with the labels on the left and the values on the right. Suppose you want some or all fields to show next to each other instead of stacked on top of each other, for a 2 or even 3 column layout. You'll also want it to wrap back to a single column for small screen layouts. If this is what you want, follow the instructions below:

At Admin Panel -> Themes -> Manage Templates -> "Listing Details" (or Listing Details + Comments), find

<table class="detailedinfo stripeme">
<!-- BEGIN DISPLAY FIELD -->
<IF {LINKSHOWFIELD[{FIELDCATEGORIES} <,> {FIELDLISTINGTYPES}]}>
<IF {FIELDNAME} is not title and {FIELDHASVALUE}>
<tr class="field{FIELDNAME}">
<td class="nowrap detailedlabels"><IF {FIELDNAME} is tags>{LANG_GENERAL_TAGS}<ELSE IF {FIELDNAME} is feedurl>{LANG_GENERAL_FEEDDATA}<ELSE IF {FIELDNAME} is url>{LANG_GENERAL_WEBSITE}<ELSE IF {FIELDNAME} is filefield>{LANG_SHOWLINKS_ATTACHED}<ELSE>{FIELDLABEL}</IF></td>
<td>{FIELDDISPLAYHTML}</td>
</tr>
</IF>
</IF>
<!-- END DISPLAY FIELD -->
</table>

Replace that with

<!-- BEGIN DISPLAY FIELD -->
<IF {LINKSHOWFIELD[{FIELDCATEGORIES} <,> {FIELDLISTINGTYPES}]}>
<IF {FIELDNAME} is not title and {FIELDHASVALUE}>
<div class="field{FIELDNAME} <?php if (strstr(" list-one-column-fields-here ", " {FIELDNAME} ")) { ?>onecolumn<?php } else { ?>twocolumn<?php } ?>">
<IF {FIELDNAME} is tags>{LANG_GENERAL_TAGS}<ELSE IF {FIELDNAME} is feedurl>{LANG_GENERAL_FEEDDATA}<ELSE IF {FIELDNAME} is url>{LANG_GENERAL_WEBSITE}<ELSE IF {FIELDNAME} is filefield>{LANG_SHOWLINKS_ATTACHED}<ELSE>{FIELDLABEL}</IF>
<br>
{FIELDDISPLAYHTML}
</div>
</IF>
</IF>
<!-- END DISPLAY FIELD -->
<div class="clear"></div>


Then go to the "Stylesheet" template and add this at the top or bottom:
.twocolumn { float: left; width: 49%; }
.onecolumn { float: left; width: 99%; }
@media screen and (min-width: 1px) and (max-width: 600px) { .twocolumn { float: left; width: 99%; } }


This will create a layout with two fields per row. If there are particular fields you'd like to take the full width instead of half-width, go back to the Listing Details template and replace list-one-column-fields-here with the names of fields you want to have use the full width, with each field name surrounded by spaces. For example, " address tags " to make the address and tags fields use the full width. You'll need to use the official database field names. To find those, go to Admin Panel -> Listings -> Listing Fields and click to edit the desired field. You'll see something like this at the top (since version 9.0.28 Beta 3): "To display this field in any template location that a link is applicable to, use {LINKCATID}. The official database name of the field is catid, if you're editing a field display area of a template you can use <IF {FIELDNAME} is catid>something to show only for catid</IF>" -- in this example the field name you want is catid.

You'll also have to careful about the display order you set for fields at Admin -> Listings -> Listing Fields to make sure that you pair off the two column ones. For example, if your first field is two columns but your second field is one column you'd end up with an empty half-column after the first field so you'd need to move another field to fill that spot.

To do three columns of fields instead of two, edit the stylesheet and change .twocolumn { float: left; width: 49%; } to .twocolumn { float: left; width: 33%; }

]]>
Make registration easier from some countries Suppose you've set your member registration to require email verification, or even to manual validation or invite-only due to a high volume of spam. https://scripts.webmastersite.net/wsnclassifieds/manual/extending/individual-hacks/make-registration-easier-from-some-countries-639.html Tue, 07 Oct 2014 01:19:47 GMT https://scripts.webmastersite.net/wsnclassifieds/manual/extending/individual-hacks/make-registration-easier-from-some-countries-639.html geolocation installed on the site.

Save the following code to /modifications/registration-begin.php (if you don't have a /modifications/ subdirectory, create it first):

<?php

if ($thismember->isguest())
{
$whitelistcountries = "United States,Canada,United Kingdom";
$ourcountry = $thismember->ipcountry();
if (strstr(",$whitelistcountries,", ",$ourcountry,")) $settings->registration = 'direct';
}

?>


Make sure you don't leave any spaces or newlines before <?php or after ?>.

The example above allows direct registration (no email verification) for anyone from the United States, Canada or United Kingdom. The rest of the world follows the registration setting you've selected at Admin Panel -> Members -> Member Settings. Possible values are:
direct - fully trusted
email - must click link in email to verify
validate - must be manually reviewed by admins
emailandmanual - must click link in email to verify, and then wait for admin to approve
invite - registration is by invitation-only
adminonly - only an admin can manually register people
disable - nobody can register

If you want to use a blacklist instead of a whitelist, just list bad countries and change 'direct' to the desired higher level of verification.]]>
Archiving Comment Posts Improving database speed on a site with millions of posts. https://scripts.webmastersite.net/wsnclassifieds/manual/extending/individual-hacks/archiving-comment-posts-588.html Fri, 29 Mar 2013 07:39:20 GMT https://scripts.webmastersite.net/wsnclassifieds/manual/extending/individual-hacks/archiving-comment-posts-588.html WSN is highly scalable, but millions of long comment posts on a very popular website can slow down database queries on that table severely and increase hardware requirements. This mainly applies to discussion forums (WSN Forum), of course. Post searches end up taking interminably long and putting pressure on the server.

One solution is to archive old posts in threads which haven't had a reply in over a year. First, make sure you're running WSN 8.0.0 Alpha 6 or later. Then, go into phpmyadmin (in your web hosting control panel) and click on the yourprefix_comments table. Go to the operations tab, and use that to copy the table structure and data to yourprefix_archivedcomments.

Then run this SQL query at Admin -> Miscellaneous -> Advanced Options:

UPDATE {PREFIX}links SET archived=1, threadclosed=1 WHERE lastcomment < UNIX_TIMESTAMP()-86400*365;

You can change 365 to a desired number of days.

Finally, you'll need to run a utility to delete posts from the regular comments table. Save the following as a 1postdeleter.php file in your WSN folder:

<?php
require 'start.php';

if (!$start) $start = 0;
$perpage = 50;

$q = $db->select('id', 'linkstable', 'archived=1', "ORDER BY id ASC", "LIMIT $start,$perpage");

$n = $db->numrows($q);
if (!$n) die("Complete");
for($x=0;$x<$n;$x++)
{
$lid = $db->rowitem($q);
if ($lid) $db->delete('commentstable', "linkid = $lid");
}
$start += $perpage;
echo "Continuing from $start... <meta http-equiv='refresh' content='5;url=1postdeleter.php?start=$start'>";
?>
Now visit that file in your web browser and leave it running for a few hours untli it says complete. At this point, your site will be running much more efficiently and all posts not replied to for a year are locked. You might want to put a note in the view thread template about being archived due to age: <IF {LINKARCHIVED}><div class="alert">This thread has been archived due to age, you will need to start a new topic if you want to continue the discussion.</div></IF>
]]>
Member Slideshows How to add a slidehow of a member's images to their profile. https://scripts.webmastersite.net/wsnclassifieds/manual/extending/individual-hacks/member-slideshows-584.html Mon, 18 Feb 2013 01:47:51 GMT https://scripts.webmastersite.net/wsnclassifieds/manual/extending/individual-hacks/member-slideshows-584.html
<!-- BEGIN TOPLIST -->
<CONFIG>attachments[,]time[,]1[,]descending[,]deleted=0 AND memberid={MEMBERID} AND (filetitle LIKE '%.jpg' OR filetitle LIKE '%.jpeg' OR filetitle LIKE '%.png' OR filetitle LIKE '%.gif')[,][,]0[,]0[,]0[,]1[,][,]0[,]0[,][,]0[,][,][,]</CONFIG>
<a href="{ATTACHSLIDEURL}" title="{ATTACHLABEL}" rel="lightbox[member{MEMBERID}attachments]" id="firstslide">Start {MEMBERNAME}'s Slideshow</a>
<!-- END TOPLIST -->

<div class="lightboxgallery" style="display: none; height: 0;">
<!-- BEGIN TOPLIST -->
<CONFIG>attachments[,]time[,]500[,]descending[,]deleted=0 AND memberid={MEMBERID} AND (filetitle LIKE '%.jpg' OR filetitle LIKE '%.jpeg' OR filetitle LIKE '%.png' OR filetitle LIKE '%.gif')[,][,]0[,]0[,]0[,]1[,][,]0[,]0[,][,]0[,][,][,]</CONFIG>
<IF {NUMBER} is greater than 1><a href="{ATTACHSLIDEURL}" title="{ATTACHLABEL}" rel="lightbox[member{MEMBERID}attachments]"></a></IF>
<!-- END TOPLIST -->
</div>


You can customize the "Start {MEMBERNAME}'s Slideshow" link as you like. If you want to have the slideshow launch by clicking on a 500x300 thumbnail of the first image, just replace Start {MEMBERNAME}'s Slideshow with <img src="{ATTACHTHUMBURL[500 <,> 300]}">

If you want to display all of the slideshow's thumbnails in advance to let the viewer launch it in the middle, delete style="display: none; height: 0;" and then change rel="lightbox[member{MEMBERID}attachments]"></a> to rel="lightbox[member{MEMBERID}attachments]">{ATTACHTHUMBURL}</a> (of course, with a member slideshow this could be a very large number of thumbnails so not normally recommended).

If you want to automatically launch the slideshow when the page loads, without waiting for a click, just go to Admin -> Themes -> Manage Templates -> "Additional Document Ready Function Content" and insert
$("#firstslide").click();
there to simulate a click as soon as the page is loaded.]]>
Limiting Moderator Actions Using the beforemoderation function to stop moderators from doing certain things in certain places. https://scripts.webmastersite.net/wsnclassifieds/manual/extending/individual-hacks/limiting-moderator-actions-575.html Tue, 10 Jul 2012 08:53:31 GMT https://scripts.webmastersite.net/wsnclassifieds/manual/extending/individual-hacks/limiting-moderator-actions-575.html
Copy and paste the following code into a moderationcontrols.php file, and upload it to your /plugins/ subdirectory:
<?php
function beforemoderation($modaction, $modreason = '', $object = false)
{
if (is_object($object))
{
if ($object->objecttype == 'link' || $object-objecttype == 'comment')
{
if ($object->catid && $object->catid == 9)
{
if ($modaction != 'movethread' && $modreason != 'double post' && $modreason != 'spam' && $modreason != 'using forum to post advertising messages') refuseselection("Only spam and double posts should be moderated in the feedback forum.");
}
}
}
return true;
}
?>


Make sure not to leave any spaces at the beginning or end.

The above code prevents moderators from taking any action in category/forum #9 (in this case a Feedback forum) other than thread moves, double post deletions and spam deletions. Modify the above code to fit your exact needs by changing 9 to the appropriate forum number and the action and reason tests to the ones you need.]]>