Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

[ NEW PLUGIN ] Regional_Areas v1

Quote Reply
[ NEW PLUGIN ] Regional_Areas v1
I had a request from someone a few days ago; to write something that would "slice and dice" the values held in Full_Name, into sub-sections...i.e;

Code:
Europe/England/West Sussex/Rudgwick

Gets sliced up into;

Code:
* Continent => Europe
* Country => England
* State => West Sussex
* Area => Rudgwick

This gives you quite a bit more "targetting" power on category pages. i.e;

Code:
<%if State eq 'West Sussex'%>
... show something related to "West Sussex"
<%endif%>

I just run this plugin on my test install; and it all seems to work fine. Below is a working example;

Code:
Working on test
* Continent => test
Working on Europe
* Continent => Europe
Working on Europe/England
* Continent => Europe
* Country => England
Working on Europe/England/West Sussex
* Continent => Europe
* Country => England
* State => West Sussex
Working on Europe/England/West Sussex/Rudgwick
* Continent => Europe
* Country => England
* State => West Sussex
* Area => Rudgwick

DONE!!!!

The plugin can be downloaded from this post (attached), or you can find out more details here:

http://www.ultranerds.com/...bin/details/124.html

PLEASE NOTE: There is *NO README* for this plugin.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!

Last edited by:

Andy: Aug 19, 2004, 2:22 AM
Quote Reply
Re: [Andy] [ NEW PLUGIN ] Regional_Areas v1 In reply to
Andy,

Very nice! Smile

One question though: Is it possible to save these values (continent, country, state etc) to the Links table rather than the Category table?

This definitely gives more targeting power for a category, but it still leaves the links associated with a category out in the cold. For me the problem is that I have physical locations (dropzones) listed in categories organized like you describe. This location information is not stored with the rest of the listing information. This makes geocoding and mapping a lot more complex.

For me this would be perfect if it simply created the 4 additional fields in the Links table and parsed these values for every link...

Safe swoops
Sangiro
Quote Reply
Re: [sangiro] [ NEW PLUGIN ] Regional_Areas v1 In reply to
Mmm ... I guess it wouldn't be too hard. Just add the new fields to the "Links" table, and then edit the Update, so that it grabs the link ID's in that category first; and then updates the links appropriatly.

However, this would cause problems with links that are in multiple categories :(

I'll have a look at it tomorrow ... but I can't guarantee anything Frown

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] [ NEW PLUGIN ] Regional_Areas v1 In reply to
Hey Andy,

Any progress on this bad boy? Wink

Safe swoops
Sangiro
Quote Reply
Re: [sangiro] [ NEW PLUGIN ] Regional_Areas v1 In reply to
Quote:
Any progress on this bad boy?

Not yet :(

It's been very busy over the last couple of days Unsure I'll keep you posted on my progress.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] [ NEW PLUGIN ] Regional_Areas v1 In reply to
Hi Andy,

This script does a similar thing for a single field - shouldn't take much changing for the four fields
http://www.gossamer-threads.com/...i?post=264895#264895

Laura.
Quote Reply
Re: [sangiro] [ NEW PLUGIN ] Regional_Areas v1 In reply to
In Reply To:
Hey Andy,

Any progress on this bad boy? Wink

All done :)

I'm just about to update the attached version (as well as the one on our site).

You can now create the continent/country/state/city/county, for both links and categories.

Enjoy :)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [sangiro] [ NEW PLUGIN ] Regional_Areas v1 In reply to
Here is a script you can run via cron/SSH;

1) Make a new script, called "run_area_update.cgi", and put the following in it;

Code:
#!/usr/bin/perl

use strict;
use lib './';
use Links qw/$IN $DB $CFG/;
use GT::SQL;
use GT::SQL::Condition;
use Links::Plugins;
use CGI::Carp qw(fatalsToBrowser);

local $SIG{__DIE__} = \&Links::fatal;

Links::init('./');

print $IN->header();

my @Field;
$Field[0] = 'Continent';
$Field[1] = 'Country';
$Field[2] = 'State';
$Field[3] = 'Area';
$Field[4] = 'Area_SubCat';


my $cat_tbl = $DB->table('Category');

my $sth = $cat_tbl->select();

while (my $hit = $sth->fetchrow_hashref) {

print "Working on $hit->{Full_Name} \n" if $DEBUG == 1;

my @slice = split /\//, $hit->{Full_Name};

for (my $i = 0; $i <= 4; $i++) {
if ($slice[$i] && $Field[$i]) {
$cat_tbl->update( { $Field[$i] => $slice[$i] }, { ID => $hit->{ID} } ) ||
die $GT::SQL::error;
print " * $Field[$i] => $slice[$i] \n" if $DEBUG == 1;

# now lets update links appropriatly in this category...
if ($DO_LINKS == 1) {
print "LINKS: ";
my $sth2 = $DB->table('CatLinks','Links')->select( { CategoryID => $hit->{ID} },{ isValidated => 'Yes' } );
while (my $hit2 = $sth2->fetchrow_hashref) {
$DB->table('Links')->update( { $Field[$i] => $slice[$i] }, { ID => $hit2->{ID} } ) || die $GT::SQL::error;
print " $hit2->{ID}";
}
print "\n\n"
}
}
}

}

print "\nDONE!!!!\n";

2) Change the 2 occurences of './' with '/full/path/to/your/admin/folder'.

3) Run it via cron/SSH with;

perl run_area_update.cgi &

4) That should be it :)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!