Filter Listings by Country Using TemplateCodes Module – How to

As I said in the TemplateCodes.com system review, the Listing Filter module can filter ads by State or using an extra (custom) field but can’t be setup to filter by countries. There’s a way to make it do that though but you need to mess with the gears of the system, opening & editing a number of PHP files.

Note: I'm not a programming guru, I used some code hints & went through trials & failures to make this work & it may not be the best way to do it. Please backup your files & even database before you proceed & be careful when altering the codes.

1st, if it’s enabled, you may want to deactivate the Listing Filter module from your 68Classifieds admin panel before you start editing & uploading files.

2. Now go & open the index.php located in yoursite.com/modules/listingfilter/ , use Notepad++ or a similar text editor.

Find these lines:

if (empty($config['lfilter_field'])) {$sSQL = "SELECT name FROM " . PREFIX . "states ORDER BY name";

Do the same, look for 'users AS u WHERE p.owner=u.id AND u.state=' & replace u.state with u.country

That's it! Now you can activate your module & see the result. But you should remember, if later you decide that you want to use the filter with an extra field instead of countries, before you do that get back the files to their original state!