Gossamer Forum
Home : Products : DBMan : Customization :

Help! Inserting field contents into a URL

Quote Reply
Help! Inserting field contents into a URL
Can anyone help me with this ?

I need the entire contents of say, 'field 0' to be inserted into a URL in a new 'field 2'.

E.G.

The contents of default.db is;
1|Record01|misc
2|Record02|misc
2|Record03|misc

I want do a search for all records and the following is displayed;

Record01 misc Link with this URL
<a>http://example.com/cgi-bin/abc.pl?=Record01</a>

Record02 misc Link with this URL
<a>http://example.com/cgi-bin/abc.pl?=Record02</a>

Record03 misc Link with this URL
<a>http://example.com/cgi-bin/abc.pl?=Record03</a>

I understand that this effect could be achieved by running a macro on default.db, however, default.db changes so often
that running a macro every time it changes wouldn't be practical.

Thanks in advance.

Dezire

Quote Reply
Re: Help! Inserting field contents into a URL In reply to
I'm somewhat confused by what you are asking, but If I understand correctly you would like the output of the field to be displayed as a url.

This can easily be accomplished by using in your html_record display. This is of course assuming that url will remain the same for each link.

I'm also using in the example the field name as record_id .. you would rename this to the field name used in your .cfg file.

<A HREF="http://example.com/cgi-bin/abc.pl?=$rec{'record_id'}>$rec{'record_id'}</A>

If this is not what you are trying to do please explain again so that we can help you find a solution.

If you want to copy a field content to another field there are threads related to this in the FAQ noted below in the section "Fields"

Unoffical DBMan FAQ
http://webmagic.hypermart.net/dbman/
Quote Reply
Re: Help! Inserting field contents into a URL In reply to
Thanks LoisC !

<A HREF="http://example.com/cgi-bin/abc.pl?=$rec{'record_id'}">$rec{'record_id'}</A>

... almost works. DBman seems to be adding unwanted html though. The code above cretes this URL;

http://example.com/cgi-bin/abc.pl?=<b>example</B><B></B>

Do you have any idea how I can remove the <b> </B><B></B>
$db_bold = 0;

??!!

Dezire



Quote Reply
Re: Help! Inserting field contents into a URL In reply to
Oooops, just checked $db_bold and it was set to 1
It works now.

No bold search results now though :(

Can anyone think of a workaround this ?

Thanks again LoisC

Dezire

Quote Reply
Re: Help! Inserting field contents into a URL In reply to
In your html_record or html_record_long (wherever you are using the $rec{'record_id'} add the following line where indicated:

my (%rec) = @_;
$rec{'record_id'} =~ s/<?.B>//g;





Quote Reply
Re: Help! Inserting field contents into a URL In reply to
Um Karen I think you mean:

Code:
$rec{'record_id'} =~ s/<.?B>//g;
or:

Code:
$rec{'record_id'} =~ s!</?B>!!g;
Wink

Installs:http://wiredon.net/gt
FAQ:http://www.perlmad.com

Quote Reply
Re: Help! Inserting field contents into a URL In reply to
$rec{'record_id'} =~ s/<.?B>//g;
or:
$rec{'record_id'} =~ s!</?B>!!g;

works a treat. Thanks !


Obviously, if $rec{'record_id'} is used again after

$rec{'record_id'} =~ s/<.?B>//g;

in a single html_record call, it remains NOT bold.
For future reference and viewers of this thread, (with as little knowledge of Perl as me :!) what is the opposite to

$rec{'record_id'} =~ s!</?B>!!g;

i.e. Can $rec{'record_id'} be made Bold again shortly after a
$rec{'record_id'} =~ s!</?B>!!g;


?
Dezire

Quote Reply
Re: Help! Inserting field contents into a URL In reply to
In Reply To:
Um Karen I think you mean:
Not sure Paul, myself and many others have used the line I posted for a very long time and it works very well. Try this thread from a couple years ago for example http://gossamer-threads.com/p/4350

I copied the line from a working file.



Quote Reply
Re: Help! Inserting field contents into a URL In reply to
You are able to hardcode bolding. The snippet will only prevent the scripts from adding bold tags.

<b>$rec{'record_id'}</b>

Quote Reply
Re: Help! Inserting field contents into a URL In reply to
Karen, I'd re-read you post Wink

Your code makes the first BRACKET optional, not the forward slash.

Installs:http://wiredon.net/gt
FAQ:http://www.perlmad.com

Quote Reply
Re: Help! Inserting field contents into a URL In reply to
Yeah, <b>$rec{'record_id'}</b> did the trick.
Blindingly simple.

.. and so the sun has come out, the birds have started singing and The Four Seasons can be heard in the distance.
Well, .... in the UK anywayz :)

THX Paul, Karen and LoisC.
Dezire