Gossamer Forum
Home : Products : Links 2.0 : Customization :

Added new fields - but the DON'T SHOW UP in add.html ...

Quote Reply
Added new fields - but the DON'T SHOW UP in add.html ...
Hi,

for tailoring Links 2 to my needs, I added some more fields to it, like "Language" (German/English), "Keywords" and "AltCategories".

Everything's ok with the admin screen; the new fields appear and they work fine.

For whatever reason (lost my brain? Wink), I don't get them to show up on add.html, add-sucess.html... Frown

Here's a snipplet of modified code of my links.def:

Code:
# Definition of your database file.
%db_def = (
ID => [0, 'numer', 5, 8, 1, '', ''],
Title => [1, 'alpha', 40, 75, 1, '', ''],
URL => [2, 'alpha', 40, 75, 1, 'http://', '^http|news|mailto|ftp'],
Date => [3, 'date', 15, 15, 1, \&get_date, ''],
Category => [4, 'alpha', 0, 150, 1, '', ''],
Description => [5, 'alpha', '40x3', 500, 0, '', ''],
'Contact Name' => [6, 'alpha', 40, 75, 1, '', ''],
'Contact Email' => [7, 'alpha', 40, 75, 1, '', '.+@.+\..+'],
Hits => [8, 'numer', 10, 10, 1, '0', '\d+'],
isNew => [9, 'alpha', 0, 5, 0, 'No', ''],
isPopular => [10, 'alpha', 0, 5, 0, 'No', ''],
Rating => [11, 'numer', 10, 10, 1, 0, '^[\d\.]+$'],
Votes => [12, 'numer', 10, 10, 1, 0, '^\d+$'],
ReceiveMail => [13, 'alpha', 10, 10, 1, 'Yes', 'No|Yes'],
Language => [14, 'alpha', 0, 10, 1, '', ''],
AltCategories => [15, 'alpha', 0, 500, 0, '', ''],
Keywords => [16, 'alpha', '40x2', 500, 0, '', '']
);

# Database file to use -- defined in links.cfg.
$db_file_name = $db_links_name;
# Counter file to use -- defined in links.cfg.
$db_id_file_name = $db_links_id_file_name;
# The column name for the database key.
$db_key = 'ID';
# Database delimeter.
$db_delim = '|';
# Title used in admin output.
$html_title = 'Links Database';
$html_object = 'Link';

# Field Number of some important fields. The number is from %db_def above
# where the first field equals 0.
$db_category = 4; $db_modified = 3; $db_url = 2;
$db_hits = 8; $db_isnew = 9; $db_ispop = 10;
$db_contact_name = 6; $db_contact_email = 7; $db_title = 1;
$db_votes = 12; $db_rating = 11; $db_mail = 13;
$db_language = 14; $db_altcategories = 15; $db_keywords = 16;

# Field number to sort links by:
$db_sort_links = 1;

# Field names you want to allow visitors to search on:
@search_fields = (1,2,5,16);

# System defaults. When adding new links or modifying links, these fields
# can not be overwritten by a user.
%add_system_fields = (
isNew => 'No',
isPopular => 'No',
Hits => '0',
Rating => 0,
Votes => 0,
ReceiveMail => 'Yes'
);

# 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',
ReceiveMail => 'Yes,No',
Language => 'Deutsch,Englisch'
);

What must I do to call them from add.html etc. ???

Maybe something magic....?

For example, I tried to get the AltCategories showing up by both, using <%AltCategories%> and <%altcategories%>, analog to <%Language%> and <%language%> - for the case the call is case-sensitive!

The result?:
Quote:
Unkown Tag: keywords
Unkown Tag: altcategories
Unkown Tag: language

Could you please tell me what to do?

Thanx in advance so much !!!

[This message has been edited by Kodak (edited August 24, 1999).]
Quote Reply
Re: Added new fields - but the DON'T SHOW UP in add.html ... In reply to
The tags for those fields in links.db are not used in add.html or modify.html. The reason is, you have not passed any record values to the load_template routine at that point. Instead, you use normal <input> tags in the add.html (for example) template with the name value set to the field's name. For the AltCategories, you need to create a <select> list in sub site_html_add_form of site_html_templates.pl, and then pass it to the template via load_template. Look in that subroutine to see how it is similarly done for the Category field.

I hope this helps.
Quote Reply
Re: Added new fields - but the DON'T SHOW UP in add.html ... In reply to
Hi Bobsie,

thanx for your help. I did modify my add.html and at least "Keywords" and "Language" seem to work...

BUT there are some problems with my modification to sub site_html_add_form of site_html_templates.pl Frown Frown Frown
that should make "AltCategories" to show up in add.html !

Here's the code, please forgive me, but I'm really very very new to Perl, so I don't actually know exactly what to do:

Code:
sub site_html_add_form {
# --------------------------------------------------------
# This routine determines how the add form page will look like.
#
&html_print_headers;

my $category = shift;
# ***************************************** nonenglish modification - begin ****************
# $category ?
# ($category = qq~$category <input type=hidden name="Category" value="$category">~) :
# ($category = &build_select_field ("Category", "$in{'Category'}"));
my ($kategorie) = &kategorie_title_mb ($category);
$category ?
($category = qq~$kategorie <input type=hidden name="Category" value="$category">~) :
($category = &build_select_field ("Category", "$in{'Category'}"));
# ***************************************** nonenglish modification - end ******************

print &load_template ('add.html', {
Category => $category,
%globals

my $altcategories = shift;
$altcategories ?
($altcategories = qq~$altcategories <input type=hidden name="AltCategories" value="$altcategories">~) :
($altcategories = &build_select_field ("AltCategories", "$in{'AltCategories'}"));

print &load_template ('add.html', {
AltCategories => $altcategories,
%globals

});
}

And here we have part of the error message, that shows up after runnig nph-build.cgi:

Quote:
Error including libraries: syntax error at [..]htdocs/cgi-bin/suche/admin/site_html_templates.pl line 239, near "my"
Missing right bracket at [..]htdocs/cgi-bin/suche/admin/site_html_templates.pl line 537, at end of line

Make sure they exist, permissions are set properly, and paths are set correctly.

Could you please tell me what to do to get it fixed? Smile Smile
Quote Reply
Re: Added new fields - but the DON'T SHOW UP in add.html ... In reply to
You are missing a closing bracket at:

Quote:
print &load_template ('add.html', {
Category => $category,
%globals

You need to add in a } bracket.

Cheers,

Alex
Quote Reply
Re: Added new fields - but the DON'T SHOW UP in add.html ... In reply to
Alex,

I will try it, but I think there's a bracket in the next line, but I'll give it a try!

And what about that line 537 stuff? I didn't change anything down there!

Thanx again and please stay tuned!


[This message has been edited by Kodak (edited August 25, 1999).]
Quote Reply
Re: Added new fields - but the DON'T SHOW UP in add.html ... In reply to
Alex & Bobsie,

after finally adding the closing bracket(s) to the place Alex indicated and running nph-build.cgi, the content of add.html has been printed twice, with some strange error message.

Well, after removing the "print" in front of "&load_template", it's ok, but there is still the following error-message showing up at the place, where normally the AltCategories should be:

Code:
sub site_html_add_form {
# --------------------------------------------------------
# This routine determines how the add form page will look like.
#
&html_print_headers;

my $category = shift;
# ***************************************** nonenglish modification - begin ****************
# $category ?
# ($category = qq~$category <input type=hidden name="Category" value="$category">~) :
# ($category = &build_select_field ("Category", "$in{'Category'}"));
my ($kategorie) = &kategorie_title_mb ($category);
$category ?
($category = qq~$kategorie <input type=hidden name="Category" value="$category">~) :
($category = &build_select_field ("Category", "$in{'Category'}"));
# ***************************************** nonenglish modification - end ******************

print &load_template ('add.html', {
Category => $category,
%globals
});
my $altcategories = shift;
$altcategories ?
($altcategories = qq~$altcategories <input type=hidden name="AltCategories" value="$altcategories">~) :
($altcategories = &build_select_field ("AltCategories", "$in{'AltCategories'}"));

&load_template ('add.html', {
AltCategories => $altcategories,
%globals

});
}

Do I have to define AltCategory somewhere else? Do you have any idea, where to look for it?

HELP & Thanx
Quote Reply
Re: Added new fields - but the DON'T SHOW UP in add.html ... In reply to
Huhu,

where are you Alexs, Eliots, Bobsies, Widgetzs, GURUs ???

Don't take me serious, but this AltCategories stuff really drives me crazy!

I did exactly do, what the mod instructions told me, but...?

Come on, any help possible? Smile Smile Smile
Quote Reply
Re: Added new fields - but the DON'T SHOW UP in add.html ... In reply to
Kodak,

Why are you loading the template twice? Here is how your code should look:

Code:
sub site_html_add_form {
# --------------------------------------------------------
# This routine determines how the add form page will look like.
#
&html_print_headers;

my $category = shift;
# ***************************************** nonenglish modification - begin ****************
# $category ?
# ($category = qq~$category <input type=hidden name="Category" value="$category">~) :
# ($category = &build_select_field ("Category", "$in{'Category'}"));
my ($kategorie) = &kategorie_title_mb ($category);
$category ?
($category = qq~$kategorie <input type=hidden name="Category" value="$category">~) :
($category = &build_select_field ("Category", "$in{'Category'}"));
# ***************************************** nonenglish modification - end ******************
$altcategories = &build_select_field ("AltCategories");

print &load_template ('add.html', {
Category => $category,
AltCategories => $altcategories,
%globals
});
}

I hope this helps.

[This message has been edited by Bobsie (edited August 26, 1999).]
Quote Reply
Re: Added new fields - but the DON'T SHOW UP in add.html ... In reply to
Hi Bobsie,

Quote:
Why are you loading the template twice?

Umm, I'm of those guys they launched the "blabla FOR DUMMIES" book-series for Wink

thank you so much for your help! Smile Smile

Well, I think we're getting closer to the final solution, since now I got a very new error message Frown Wink

Quote:
error building select field: no select fields specified in config for field 'AltCategories'!

Do I have to change something in links.cfg or what config is this message "talking" about?

I don't know why this mod won't work with my place...? Crazy stuff!

Any idea?

[This message has been edited by Kodak (edited August 26, 1999).]
Quote Reply
Re: Added new fields - but the DON'T SHOW UP in add.html ... In reply to
I assume your select list of alternate categories should be the same as your regular categories (just going to a different field), right? If so, change it to read:

Code:
$altcategories = &build_select_field ("Category");

I hope this helps.
Quote Reply
Re: Added new fields - but the DON'T SHOW UP in add.html ... In reply to
Bobsie,

you're the GREATEST - it works....!

ahemmm, but I don't know why this happened:


After applying what you told me and running nph-build, I entered a new link via add.html and went over to admin.cgi to validate it...

Well there I got the big shock, instead of the Link-ID field there's been a category select box! Link-ID passed somewhere over to the moon ? Frown

When I want to modifiy one of my links now, since there's no ID-field any more, it gives my this output (if I don't "touch" the "new" ID-field):

Quote:
Error: Unable to Modify Link

There were problems modifying the record:
ID (Can not be left blank)

Please fix any errors and submit the record again.

If I do select one of the categories within the "new" ID-field, it shows me that output:

Quote:
Error: Unable to Modify Link

There were problems modifying the record:
ID (Too long. Max length: 8)

Please fix any errors and submit the record again.

What could have been the cause for that? I don't know how I could have damaged some other code, since I did just change the code mentioned in this thread!

I don't want to be a pain to you Bobsie...
I don't know what to do next. Maybe I should just forget about that MultipleCategories mod since it doesn't like me at all!?

What do you suggest?

If it helps, I may email you the URL of my Admin.cgi, so you may just have a glimpse on what I tried to explain here...

Thank you for any help you can provide and also for all your past help,

Kodak

PS: Just tell me, when when you think I should open a new thread for discussing the
new problem...

[This message has been edited by Kodak (edited August 26, 1999).]
Quote Reply
Re: Added new fields - but the DON'T SHOW UP in add.html ... In reply to
I guess you have an AltCategories field defined in your links.def, right? And the links.db had all old records updated to use the new field? Did you define anything for the AltCategories in links.def's %db_select_fields hash?

To be honest with you, I am really not all that familiar with this mod other than answering general questions as I have up to this point. I am interested in the mod though because I can see its usefulness. What I am getting at is, I would need access via ftp to see if I could figure it out. The admin.cgi would only let me see the results of the error, not diagnose the error. If you want to, send me ftp information and I will see what I can do, although I cannot guarantee exactly how long it would take me.
Quote Reply
Re: Added new fields - but the DON'T SHOW UP in add.html ... In reply to
Hi Bobsie,

yeah, thanx for offering your help. Smile Smile Smile Smile SmileI will send you my FTP password and username and all the other necessary info via Email.

Kodak
Quote Reply
Re: Added new fields - but the DON'T SHOW UP in add.html ... In reply to
Hey Kodak,

Still here...Looks like Bobsie is assisting you..Good. He knows what he is talking about.

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Quote Reply
Re: Added new fields - but the DON'T SHOW UP in add.html ... In reply to
Hi Eliot,

yes, it looks like this mod dislikes me.... Frown Frown Frown

Today I sent Bobsie my access-data for FTP and hope so much that he'll find the reason for that odd problems. Maybe it's odd Kodak?

The good thing about all that is the fact, that it helps you (-->me) to understand Links much more and even get the first steps in Perl programming.

Hopefully one day I may help others the same way, too.


Hi Bobsie,
just to give you best information:
I did just modify the calls for AltCategories/Categories within add.html not add_success.html ... but don't think that matters. Or does it?

Kodak

[This message has been edited by Kodak (edited August 29, 1999).]