Gossamer Forum
Home : Products : DBMan : Customization :

pass a variable from outside

Quote Reply
pass a variable from outside
Dear all..

After virtuous programming and planing I was running in a problem of controlling the optics of my pages.

My database contains a field called "Kat" for each record. The field "Kat" holds the information to which category the record belongs. This makes sense because I am using this variable in order to control the background graphics and the content of a navigation bar with the value stored in the variable "Kat".

But since I started thinking about search options for a default user I was running in a problem. The problem is the following:
The default user reaches the subroutine "sub html_view_search" directly by means of a call from a menu point in the navigation bar. The call looks like:
http://www.myserver.com/cgi-bin/db.cgi?db=listenl&uid=default&view_search=1
This leads to the result that the background graphics do not appear and the navigation bar shows an error.

A nice solution that would fit in my concept would be to pass a variable from the call of the URL through the application into the subroutine "sub html_view_search" in order to make the variable available in the subroutine "sub html_view_search". Lets name the variable "extra" . The call that I like to do could look like:

http://www.myserver.com/cgi-bin/db.cgi?db=listenl&uid=default&view_search=1&extra=kat1

This could display the search form with background pictures and navigation bar in accordance to category 1.


If this is possible I would like to use the variable within "sub html_view_search". From there I would like to pass it by the help of the line:

|; &html_record_form(); print qq|

into the subroutine "sub html_record_form".

Is anybody aware how to solve my difficulties.??

Sincerely michaels


Quote Reply
Re: pass a variable from outside In reply to
You can pass anything you want from a URL to a script. Using your example, when you want to refer to the variable, use $in{extra}.

So, you could say something like

Code:

if ($in{extra} eq kat1) {
do something;
}
JPD
http://www.jpdeni.com/dbman/