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.
Apr 2, 2013, 2:13 AM
Veteran / Moderator (18441 posts)
Apr 2, 2013, 2:13 AM
Post #2 of 4
Views: 6347
Hi,
Why not make a common function that will just hold them as options? For example:
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:
Then call with stuff like:
Not sure how practice that is with your setup - but its worth a go
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!
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} , etcNot sure how practice that is with your setup - but its worth a go
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!
Apr 3, 2013, 12:20 AM
Veteran / Moderator (18441 posts)
Apr 3, 2013, 12:20 AM
Post #4 of 4
Views: 6312
Hi,
I would just stick it in a .pm file you already have (and include).
Then you would call with:
Then if you have your table name held in $tbl, you could use:
$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!
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!