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

Description Formatted - Multiple Fields

Quote Reply
Description Formatted - Multiple Fields
I'm using this global to format the description field but I would like it to format multiple description fields.( 4 other fields including the description)
I can just make 4 copies of this but thought there may be a better way.

sub {

my $tags = shift;

my $Description = $tags->{Description};

$Description = GT::CGI::html_escape($Description);

$Description =~ s/\n/<BR>\n/g;

$Description =~ s,\[([/\w\s#"=;:{}]+)\],<$1>,g;

return $Description;

}

ie Description,Description1,Description2,Description3,Description4.

Any pointers.

Thanks

Regards

minesite
Quote Reply
Re: [minesite] Description Formatted - Multiple Fields In reply to
sub {
my $Description = shift;
$Description = GT::CGI::html_escape($Description);
$Description =~ s/\n/<BR>\n/g;
$Description =~ s,\[([/\w\s#"=;:{}]+)\],<$1>,g;
return $Description;
}

Then use <%globalname($Description1)%> etc.
Quote Reply
Re: [minesite] Description Formatted - Multiple Fields In reply to
This should work. You need to pass in the field name.. i.e <%global($FieldNameToFormat)%>;

Code:
sub {

my $field_content = $_[0];
$field_content = GT::CGI::html_escape($field_content);

$field_content =~ s|\n|<BR>\n|g;
$field_content =~ s,\[([/\w\s#"=;:{}]+)\],<$1>,g;

return $field_content;

}

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: [afinlr] Description Formatted - Multiple Fields In reply to
Less than a minute between us, huh Laura? 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!
Quote Reply
Re: [Andy] Description Formatted - Multiple Fields In reply to
Thanks and Thanks.

Regards

minesite
Quote Reply
Re: [Andy] Description Formatted - Multiple Fields In reply to
Tongue Good to see we both came up with the same solution!
Quote Reply
Re: [afinlr] Description Formatted - Multiple Fields In reply to
In Reply To:
Tongue Good to see we both came up with the same solution!

Indeed. It should also be faster, as you are not passing in the whole set of variables, but instead just the one variable that actually needs to be worked on :)

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!