Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Problem displaying ADD_NOTNULL Lang. Error

Quote Reply
Problem displaying ADD_NOTNULL Lang. Error
Hey,

I've been bothered for some time by the way certain <%error%> messages like ADD_NOTNULL from the language file are displayed. For some reason Unorderlist tags are being inserted that makes my layout look a little off. Other errors only return the text located in the Language file. Here's what's being returned for ADD_NOTNULL:

<ul><ul><li>Review Title can not be left blank.</ul></ul>

How in the world do I get rid of those double <ul> tags???

Must have spent two hours looking for the code that causes this output. Hopefully someone can point me in the right direction.

Thanks
Quote Reply
Re: [Jonze] Problem displaying ADD_NOTNULL Lang. Error In reply to
Mmm. Have you looked in Build > Language > 'ADD' to see if there are any <ul> tags surrounding the error text?

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] Problem displaying ADD_NOTNULL Lang. Error In reply to
Thanks for the reply Andy.

Yeah I edit those all the time. There's no <ul> tags in the language.txt at all. Those tags only seem to show up when the "ADD_NOTNULL" error is returned. I thought there was another error doing the same thing but I can't remember which one.

JUST searched around some more and finally found where it was hardcoded in the add.pm ...

# Setup the language for GT::SQL.
local $GT::SQL::ERRORS->{ILLEGALVAL} = Links::language('ADD_ILLEGALVAL');
local $GT::SQL::ERRORS->{UNIQUE} = Links::language('ADD_UNIQUE');
local $GT::SQL::ERRORS->{NOTNULL} = Links::language('ADD_NOTNULL');
local $Links::Link::ERRORS->{NOCATEGORY} = Links::language('ADD_NOCATEGORY');
$Links::Link::ERRORS ||= {}; # silence -w

# Add the record.
my $id = $db->add ( $input );
$input->{ID} = $id;
if (! $id) {
my $error = "<ul><li>" . join ("<li>", $db->error) . "</ul>";
return { error => "<ul>$error</ul>", Category => $category };
}

Not too sure why something like that would be hardcoded Crazy

Alright, I'm not to good with perl. Anyone know the best way to properly edit those tags out???
Quote Reply
Re: [Jonze] Problem displaying ADD_NOTNULL Lang. Error In reply to
You could create a new global or something. Maybe something like;

<%if error%>
<%new_error($error)%>
<%endif%>

new_error =>

Code:
sub {
my $error = shift;
$error =~ s/<ul>(.+?)<\/ul>/$1/ig;
return $error;
}

Untested, so I'm not sure how well/if it will work.

If that doesn't work, just try editing the hard coded stuff. Something like this should work;

return { error => "<ul>$error</ul>", Category => $category };

to

return { error => "$error", Category => $category };

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: May 20, 2003, 6:45 AM
Quote Reply
Re: [Andy] Problem displaying ADD_NOTNULL Lang. Error In reply to
Excellent! Wink Thanks very much for the code Andy. Works great.

I was actually trying to get rid of the <ul> tags completely, but removing one set of tags solves my spacing issues just fine. I'm also much happier using a global instead of editing code as well.

Thanks again Mon! You da bomb.

Jonze
Quote Reply
Re: [Jonze] Problem displaying ADD_NOTNULL Lang. Error In reply to
No problem. I'm suprised it was in the hard coded too. Maybe GT wanna make this template based in future versions of LSQL Wink

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!