Gossamer Forum
Home : Products : DBMan : Customization :

Find and replace

Quote Reply
Find and replace
Hi

i wish the database to show the word 'black' when the record contains the word 'white'. is it possible ?

precisely, i wish to replace the 'return to line' code (not <br> but this one: ``` ) by an image in order to have a correct design.

Thanks if you can help.

Cheers

j
Quote Reply
Re: [jigme] Find and replace In reply to
Hi,

What exactly do u want?

Cheers,

Dat

Programming and creating plugins and templates
Blog
Quote Reply
Re: [tandat] Find and replace In reply to
Sorry, i didn t explain clearly.
i want the word 'white' (as example) recorded in the database to be displayed as the word 'black'. Or any word 'white' to be displayed as an image 'white.gif' instead of the word 'white'.

i wish it is clearer.Wink

tanx if you have an idea
Quote Reply
Re: [jigme] Find and replace In reply to
It still isn't clear Cool

First you said you want the word white displayed as black then you said you want an image?
Quote Reply
Re: [RedRum] Find and replace In reply to
Argh
my frenglish is so bad and programming knowledge tooAngelic. ok i try once again, thanx for your patience.Wink

i guess that you understood that i want the word WHITE (or MOTHER) displayed as BLACK (or MUMMY or whatever).

let s forget about the image for now, but my next question will be 'how do i replace the word 'MUMMY' by the IMAGE of Mummy.

if it is still not clear, i go to doctor Sly

Cheers

j
Quote Reply
Re: [jigme] Find and replace In reply to
Hmm try something like:

my $string = $rec{your_field};
my @replace = qw/mummy white whatever else you want to replace/;

$string =~ s|\Q$_|<img src="/path/to/$_.gif">|ig for @replace;

Last edited by:

RedRum: Mar 7, 2002, 11:26 AM
Quote Reply
Re: [RedRum] Find and replace In reply to
thanx a lot, i ll try it.
please, where do i precisely write this code ?

cheers

j
Quote Reply
Re: [jigme] Find and replace In reply to
Wherever you want the field replacing. html_record ?
Quote Reply
Re: [RedRum] Find and replace In reply to
Somehow like this ? doesn t work ...


sub html_record_long {
#----------------------------------------------------------------
my (%rec) = @_;
if ($db_total_hits > 1) {

# create links to previous and next records

$next_url = $ENV{'QUERY_STRING'};
$next_url =~ s/\&nh=\d+//;
$next_hit = $nh + 1;
$prev_hit = $nh - 1;

if ($prev_hit) {
$previous = qq~~;
}
else { $previous = " "; }

if ($next_hit <= $db_total_hits) {
$next = qq~~;
}
else { $next = " "; }

# create link back to short display
$list_url = $next_url;
$list_url =~ s/\&mh=\d+//;
$mh = $db_max_hits;
$lh = int(($nh-1)/$mh) + 1;
$list = qq~~;

# print out the links
print qq||;
}

# Find <BR> and replace with empty image.
my $string = $rec{Field_Name1};
my @replace = qw/mummy white whatever else you want to replace/;

$string =~ s|\Q$_|<img src="/path/to/$_.gif">|ig for @replace;


# Below is where you define your form.

# <-- Start of record display -->
my $font_color = 'Font face="Arial, Helvetica" Size=2 Color=#003399';

print qq|
etc ...
Quote Reply
Re: [jigme] Find and replace In reply to
Quote:
# Find <BR> and replace with empty image.
my $string = $rec{Field_Name1};
my @replace = qw/mummy white whatever else you want to replace/;

$string =~ s|\Q$_|<img src="/path/to/$_.gif">|ig for @replace;



Did you change those lines to your specific needs?

# Find <BR> and replace with empty image.
my $string = $rec{Field_Name1}; # Change to your actual field name
my @replace = qw/mummy/;

$string =~ s|\Q$_|<img src="/graphics/$_.gif">|ig for @replace;