Gossamer Forum
Home : Products : Links 2.0 : Customization :

Multi category and Link templates

Quote Reply
Multi category and Link templates
I´ve tried three versions of mods now to change the template link.html for one category.

What I wish is:

I use links2.0 and sendcard for greeting cards

http://post.schwarzwald.ag

Now I want to take also flash pictures. For that I have to change <img... into <embed...

It works great in the category flash, but it doesn´t work in search.cgi and in lastlink.cgi and I think it will not work in detailed.html, rate,.... There it takes the template link.html and the flash picture doesn´t appear.

I use now the mod from this site:

http://cgi-resource.co.uk/pages/multcat2.shtml

Can you help me?

I´m afraid now, the easiest way is to install the script another time for flash.

Greetings Elke
Quote Reply
Re: [Elke] Multi category and Link templates In reply to
Why not add a new field in links.def (i.e. Type, then options as flash, gif), and then in link.html try something like;

Code:
<%if Type eq flash%>
;;;flash stuff can go here;;;
<%endif%>

<%if Type eq gif%>
;;;image/gif stuff can go here;;;
<%endif%>

Hopefully that is more simple than what you are doing at the moment ;)

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!
Quote Reply
Re: [Andy.] Multi category and Link templates In reply to
O thank you very much.

I think this could be better.Smile

Can you help me with the links.def?

There is nothing similar in it, so that I don´t know how it must look like.And I ´m not firm in these things.Crazy

Here is the part of the link.def I think you mean.



Quote:


%db_def = (
ID => [0, 'numer', 5, 8, 1, '', ''],
Name => [1, 'alpha', 40, 75, 0, '', ''],
'Contact Email' => [2, 'alpha', 40, 75, 0, '', '.+@.+\..+'],
Homepage => [3, 'alpha', 40, 75, 0, 'http://', '^http|news|mailto|ftp'],

Date => [4, 'date', 15, 15, 0, \&get_date, ''],
Category => [5, 'alpha', 0, 150, 1, '', ''],
LogoURL => [6, 'alpha', 60, 150, 1, 'http://www.', ''],
Suchwoerter => [7, 'alpha', '40x2', 200, 0, '', ''],
Hits => [8, 'numer', 10, 10, 1, '0', '\d+'],
isNew => [9, 'alpha', 0, 5, 0, 'Yes', ''],
isPopular => [10, 'alpha', 0, 5, 0, 'No', ''],
Rating => [11, 'numer', 10, 10, 1, 0, '^[\d\.]+$'],
Votes => [12, 'numer', 10, 10, 1, 0, '^\d+$'],
LogoURLvor => [13, 'alpha', 60, 150, 1, 'http://www.', ''],
);


thank you for your help



greetings



Elke
Quote Reply
Re: [Elke] Multi category and Link templates In reply to
Hi,

It could be


%db_def = (
ID => [0, 'numer', 5, 8, 1, '', ''],
Name => [1, 'alpha', 40, 75, 0, '', ''],
'Contact Email' => [2, 'alpha', 40, 75, 0, '', '.+@.+\..+'],
Homepage => [3, 'alpha', 40, 75, 0, 'http://', '^http|news|mailto|ftp'],

Date => [4, 'date', 15, 15, 0, \&get_date, ''],
Category => [5, 'alpha', 0, 150, 1, '', ''],
LogoURL => [6, 'alpha', 60, 150, 1, 'http://www.', ''],
Suchwoerter => [7, 'alpha', '40x2', 200, 0, '', ''],
Hits => [8, 'numer', 10, 10, 1, '0', '\d+'],
isNew => [9, 'alpha', 0, 5, 0, 'Yes', ''],
isPopular => [10, 'alpha', 0, 5, 0, 'No', ''],
Rating => [11, 'numer', 10, 10, 1, 0, '^[\d\.]+$'],
Votes => [12, 'numer', 10, 10, 1, 0, '^\d+$'],
LogoURLvor => [13, 'alpha', 60, 150, 1, 'http://www.', ''],
Type => [14, 'alpha', 10, 5, 0, '', '^gif|jpeg|jpg|png|swf'],

);

Cheers,

Dat

Programming and creating plugins and templates
Blog
Quote Reply
Re: [tandat] Multi category and Link templates In reply to
Oh Thanks,

I notices it tonight ( in the sleep) - I thought too difficult.Unsure

I thought I must make something that automaticly recognize if it is a gif or a flash.

But I will have a nother field in my amin and I can set it.

It is like new.

Perhaps I must change also
Quote:
# System defaults. When adding new links or modifying links, these fields
# can not be overwritten by a user.
%add_system_fields = (
isNew => 'Yes',
isPopular => 'No',
Type => 'gif', Hits => '0',
Rating => 0,
Votes => 0,
ZIELURL => 'http://schwarzwaldsuche.de/gruss/index.php',
);
# Hash of column names to possible options. If you want to use a select form
# field, you can use &build_select_field in your HTML page. This routine will
# make a <SELECT> input tag using the following values:
%db_select_fields = (
isNew => 'Yes,No',
isPopular => 'Yes,No', Type =>'gif,flash', );

I hope I must not change all links (over 400) by myself ;-)

Thanks for the answer

greetings

Elke

(sorry for my bad English)
Quote Reply
Re: [Elke] Multi category and Link templates In reply to
Do you need a script to modify all the existing entries to accomidate this new field?

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!
Quote Reply
Re: [Andy.] Multi category and Link templates In reply to
Hallo Andy,

if you have one it would be great.

greetings Elke
Quote Reply
Re: [Elke] Multi category and Link templates In reply to
Don't have one to hand, but I could write a simple one for you. Just post a sample line of links.db here in the forum for me, and I'll see what I can do.

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!
Quote Reply
Re: [Andy.] Multi category and Link templates In reply to
ShockedThat´s very nice, thank you!

Here are the first two. (I think this is very wrong EnglishBlush):


Quote Reply
Re: [Elke] Multi category and Link templates In reply to
Something like this should work;

Code:
#!/usr/bin/perl
print "Content-type: text/html \n\n";

# get the old data in an array
open(IN, "links.db") || &error("unable to open data file. Reason: $!");
@data = <IN>;
close(IN);

# open the new data file..
open(NEW, "links.db.new") || &error("unable to open data file. Reason: $!");

foreach (@data) {

chomp;

my ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14) = split("|", $_);

if ($7 =~ /.gif/) { $15 = "|gif"; }
if ($7 =~ /.swf/) { $15 = "|flash"; }

print NEW "$_$15\n";

print "Added: $_$15 <BR>";

}

# shut the new data file...
close(NEW);


sub error() {

my $error = shift;

print $error;

}

I'm not sure if the syntax is right in some places...as I havn't written a Perl script in quite a few weeks Wink

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 13, 2002, 5:11 AM
Quote Reply
Re: [Andy.] Multi category and Link templates In reply to
Eeek....that isn't going to work for sure :)

You will need something like:

Code:
#!/usr/bin/perl

print "Content-type: text/plain\n\n";

open(IN, "data/links.db") or &cgierror("unable to open data file. Reason: $!");
open(NEW, ">data/links.db.new") or &error("unable to open data file. Reason: $!");
while (<IN>) {
chomp;
split /\|/;
print NEW join('|', @_);
if ($_[6] =~ /\.(gif|swf)$/) {
print NEW "|$1";
print "Updated record $_[0].....added $1\n";
next;
}
print NEW "\n";
}
close NEW;
close IN;

It will need to go in your admin directory.

Last edited by:

Paul: Apr 13, 2002, 5:20 AM
Quote Reply
Re: [Paul] Multi category and Link templates In reply to
Erm, where are you getting $1 from?

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!
Quote Reply
Re: [Andy.] Multi category and Link templates In reply to
The hidden valley of the apes. Cool
Quote Reply
Re: [Andy.] Multi category and Link templates In reply to
Hello,

it is right,

the first one does not run.

I made a backup of links.db and tried to build all with the new links def.

This works and it look like this:

Quote:


1|Elke|elke@doebbeler.de|http://schwarzwald.ag|23-Feb-2002|Ostern|http://www.schwarzwaldsuche.de/mit/ostern/ostern2.gif|Ostern, Henne, Kücken|1|No|No|0|0|http://www.schwarzwaldsuche.de/mit/ostern/ostern2.gif|

2|Elke|elke@doebbeler.de|http://|23-Feb-2002|Blumen|http://www.schwarzwaldsuche.de/mit/blumen/bl2.gif|Blumen|0|No|No|0|0|

http://www.schwarzwaldsuche.de/mit/blumen/bl2.gif|

Can I use now something like this, than I must not have a gif behind the links

Quote:


<%if Type eq flash%>
...flash instruction

<%endif%>

<%if Type not flash%>
gif instruktion

<%endif%>


I do not know the exact order for if not or is this right? I do not believe so.

And must I put flash in '' or not?



Sorry I don´t know much about these things.

Thank you for your answers.

Elke
Quote Reply
It works!!! In reply to
SmileSlyCoolIt works!!

I use

<%if Type eq swf%>
...flash instruction
<%endif%>

<%ifnot Type eq swf%>
gif instruktion
<%endif%>



and it does not matter, if I use '' or not.

But the problem was , I had to change the template.pm with this

http://www.gossamer-threads.com/...es/Detailed/877.html

without this nothing appears.

Now you can look at:

http://schwarzwaldsuche.de/cgi-bilder/search.cgi?query=Geburtstag&mh=25&type=keyword&bool=and

and you see gif and flash-picture.



Uff, I´m very happy!

Thank you very much for your help!

Elke Sly Cool Smile