Gossamer Forum
Home : General : Perl Programming :

custom messages

Quote Reply
custom messages
i'm looking for suggestions to store and retrieve custom messages for dbman. for example, when you add a record, the subroutine has a page title and submit button that i would like to customize. the add success page also has a custom title. i want the flexibility to have different messages for different databases. i'm considering storing the messages in a config file for each database and reading all the messages at once when the config file is loaded but that seems slow, inefficient, and many unnecessary variables. would it be too slow to look up the appropriate message in a file each time a subroutine is called? any suggestions? thanks.
Quote Reply
Re: [delicia] custom messages In reply to
Hi,

Why not make a common function that will just hold them as options? For example:


Code:
sub load_options {
return {
TABLE_FOO => {
name => "bla",
title => "something else",
success_message => "whatever"
},
ANOTHER_TABLE => {
name => "bla",
title => "something else",
success_message => "whatever"
},
SOMETHING => {
name => "bla",
title => "something else",
success_message => "whatever"
},
}

}

Then load with:

Code:
my $TBL_OPTS = load_options();

Then call with stuff like:

Code:
$TBL_OPTS->{SOMETHING }->{name}, $TBL_OPTS->{SOMETHING }->{success_message} , etc

Not sure how practice that is with your setup - but its worth a go Angelic

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: Apr 3, 2013, 12:18 AM
Quote Reply
Re: [Andy] custom messages In reply to
sounds good. i think i understand sub load_options but when do i call it? from the routine(s) where i want to print my custom message? or when i load my config file? there will be a lot of variables.

then how do i print? print $TBL_OPTS->{success_message};
Quote Reply
Re: [delicia] custom messages In reply to
Hi,

I would just stick it in a .pm file you already have (and include).

Then you would call with:

Code:
my $TBL_OPTS = Module::Name::load_options();

Then if you have your table name held in $tbl, you could use:

Code:
$TBL_OPTS->{$tbl}->{name},
$TBL_OPTS->{$tbl}->{success_message}

etc

Hope that helps

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!