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

Help with A&B in global

Quote Reply
Help with A&B in global
Usage example:

Title (Manufacturer)
URL (Model Number) - Internal link to Detailed page

I'm using the global below to add a button to the Detailed page so visitors can list all other products by that manufacturer.

If the Title is Adam, it lists everything with that title.
If the Title is Adam & Eve it lists everything with that title.
If the Title is Adam&Eve it seams to list everything beginning with A.

The SQL table Title field is always entered as &.

Is there anything I can add to the global to correct this?

Code:
sub {
my $tbl = $DB->table('Links');
$tbl->select_options("ORDER BY URL");
my $title = $IN->param('title');
my $sth = $tbl->select( GT::SQL::Condition->new('isValidated','=',"Yes",'Title','LIKE',"$title%") );
my @loop;
while (my $hit = $sth->fetchrow_hashref) {
if ($CFG->{build_detailed}) { $hit->{detailed_url} = $CFG->{build_root_url} . "/" . $DB->table('Links')->detailed_url( $hit->{ID} ); }
if ($hit->{isNew} eq "Yes") { $hit->{isNew} = 1; } else { $hit->{isNew} = 0; }
if ($hit->{isPopular} eq "Yes") { $hit->{isPopular} = 1; } else { $hit->{isPopular} = 0; }
if ($hit->{isChanged} eq "Yes") { $hit->{isChanged} = 1; } else { $hit->{isChanged} = 0; }
push @loop, $hit;
}
return { links_loop => \@loop };
}

Last edited by:

MJB: Oct 23, 2010, 3:01 AM
Quote Reply
Re: [MJB] Help with A&B in global In reply to
I've done some more testing on this and it's not recognising & in the browser address bar (FF, IE8, Chrome, etc).

Anything that I type with an & in the URL returns this:

URL: xxxx=A&E
Displays: Products by A

URL: xxxx=Adam&Eve
Displays: Products by Adam

URL: xxxx=Adam & Eve
Displays: Products by Adam

So basically, anything after the & sign is being ignored.

Last edited by:

MJB: Oct 23, 2010, 5:44 AM
Quote Reply
Re: [MJB] Help with A&B in global In reply to
Thats because & is what is used to split up URL strings:

foo=1&something_else=something&whatever=abc

You probably wanna pass the string via GT::CGI::url_escape() ... that should convert it to the proper %xx value for you :)

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!