Gossamer Forum
Home : Products : Links 2.0 : Customization :

Adding Category Summarys

Quote Reply
Adding Category Summarys
I am using links 2.0 in templates and I was wondering how could I add a Summary on top of each Category?

My idea was using the mega tag and posting html to it... and place it in the proper place on the template.. it works but then I would be with out a mega tag ....

My question is how can I add another statement something like mega tag on to templates.. I want to be able to edit each category. I also want to have it in the Admin Templates just another field...

I would like to call the description up in templates something like <%catdescription%>

I like to do this (the same thing as above with my sponcers and link partners...

in the admin I would just place html accordly as they would be new fields..

A Sponcer Field and Link Partners Field
and in the templates

I would place these where I wanted them to show up..
<%sponcers%> <%linkpartners%>
Quote Reply
Re: Adding Category Summarys In reply to
ok Here is what I have.... I am wanting to add a description that I can place in my templates that I can edit in admin..

I first edited.. my categories.def from
Code:
# Definition of your database file.
%db_def = (
ID => [0, 'numer', 5, 10, 1, '', ''],
Name => [1, 'alpha', 40, 75, 1, '', '^[\w\d/_-]+$'],
Description => [2, 'alpha', '40x3', 900, 0, '', ''],
Related => [3, 'alpha', 0, 8900, 0, '', ''],
'Meta Description' => [4, 'alpha', 40, 700, 0, '', ''],
'Meta Keywords' => [5, 'alpha', 40, 700, 0, '', ''],
Header => [6, 'alpha', 40, 75, 0, '', ''],
Footer => [7, 'alpha', 40, 75, 0, '', '']
);

to


Code:
# Definition of your database file.
%db_def = (
ID => [0, 'numer', 5, 10, 1, '', ''],
Name => [1, 'alpha', 40, 75, 1, '', '^[\w\d/_-]+$'],
Description => [2, 'alpha', '40x3', 900, 0, '', ''],
Related => [3, 'alpha', 0, 8900, 0, '', ''],
'Meta Description' => [4, 'alpha', 40, 700, 0, '', ''],
'Meta Keywords' => [5, 'alpha', 40, 700, 0, '', ''],
Header => [6, 'alpha', 40, 75, 0, '', ''],
Footer => [7, 'alpha', 40, 75, 0, '', '']
CatDescription => [8, 'alpha', '40x3', 900, 0, '', ''],
);

Next I copied the modify script from http://www.gossamer-threads.com/scripts/forum/resources/Forum3/HTML/001090.html

but I was not sure what to save it as do I saved it as david.cgi -- Not sure if that was correct...? I also changed the values to point to categories instead of links..


links.def => category.def
links.db => categories.db
links2.db => categories2.db


and I was not sure which directory to place it in so I placed it in my admin folder.. the same folder that has db_utils.pl and
category.def in it...

I chomd the data directory to 777
I chomd david.cgi to 775

Here is david.cgi modified from your forum..

Code:
#!/usr/local/bin/perl
# -------------------------------------------
#You must EDIT YOUR category.def script BEFORE entering these variable and running this script!
$field_default = ""; #Put the default value of the new field here. Leave Blank for no default.
$new_field = "8"; #Put the new field number here.
$total_fields = "9"; #Put the last field number here.
#Change these value to match your settings
require "db_utils.pl";
require "category.def";

#You shouldn't have to edit below this line
#------------------------------------------
$nfm1 = $new_field - 1;

$ENV{'REQUEST_METHOD'} and (print "Content-type: text/plain\n\n");
open (DB, "<categories.db") or print "Unable to open links database 'categories.db'. Reason: $!" and exit;
print "\tOpening output file . . .\n";
open (DBOUT, ">categories2.db") or print "Unable to open output database. Make sure data dir is chmod 777 temporarily. Reason: $!" and exit;
print "\n\n\tProcessing records\n";
while (<DB> ) {
(/^#/) and next LINE; # Skip comment Lines.
(/^\s*$/) and next LINE; # Skip blank lines.
chomp; # Remove trailing new line.
@rec_in = &split_decode($_);
# Copy ID, Title, URL, Date and Category
for $i (0 .. $nfm1) {
$rec_out[$i] = $rec_in[$i];
}
# Add New Field
$rec_out[$new_field] = "$field_default";
# Copy the rest of old categories.db to new categories2.db
for $i ($new_field .. $total_fields) {
$rec_out[$i + 1] = $rec_in[$i];
}
print DBOUT &join_encode(&array_to_hash(0, @rec_out));
}
print "\tDone.\n\n";
close DB;
close DBOUT;
print "Database saved it as categories2.db.\n";
print "Change permissions back to 755 on the data directory.\n\n";
print "You must rename 'categories2.db' to 'categories.db before using with Links v2.\n";
print "It is recommend you save the original 'categories.db' before renaming.\n\n";

I got an error 500 ... I am sure I am missing very little but don't really know what yet.. can you help did I miss something?






[This message has been edited by thefreebiesite (edited May 03, 2000).]
Quote Reply
Re: Adding Category Summarys In reply to
Two suggestions...

1) Use the <%Description%> field that already comes in the category.def file out-of-the box. Then delete the $description variable in the sub site_html_print_cat routine in the site_html_templates.pl file.

2) Add another field to your category.def file and then upgrade your existing categories.db file using the script located in the Adding fields to existing links.db FAQ in the Resource Center. As mentioned before:

Replace the following values:

links.def => category.def
links.db => categories.db
links2.db => categories2.db

Quote:
A Sponcer Field and Link Partners Field

Read the same FAQ that I referenced above.

"Thinking out of the codes (box) is fun and effective."

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
Anthro TECH, L.L.C
anthrotech.com
* Check Resource Center
* Search Forums
* Thinking out of the box (codes) is not only fun, but effective.


Quote Reply
Re: Adding Category Summarys In reply to
Your problem is with the following lines:

Code:
require "db_utils.pl";
require "category.def";

You need to include the FULL ABSOLUTE PATH to these files since they are in a different directory than your data directory.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
Anthro TECH, L.L.C
anthrotech.com
* Check Resource Center
* Search Forums
* Thinking out of the box (codes) is not only fun, but effective.


Quote Reply
Re: Adding Category Summarys In reply to
ok.. I already done that.. I placed the files on a server that I can use telnet... I have this error and I don't know how to fix it..

pisces:/ > /home/referra/public_html/aaaaa/upgrade.cgi
syntax error at /home/referra/public_html/aaaaa/category.def line 31, near "CatDescription"

If you need to look here is where I placed the files ... I placed .txt so you can see what I did...

http://www.referralmaker.com/aaaaa/


It's the one I added... here is the category.def again

Code:
# Definition of your database file.
%db_def = (
ID => [0, 'numer', 5, 10, 1, '', ''],
Name => [1, 'alpha', 40, 75, 1, '', '^[\w\d/_-]+$'],
Description => [2, 'alpha', '40x3', 900, 0, '', ''],
Related => [3, 'alpha', 0, 8900, 0, '', ''],
'Meta Description' => [4, 'alpha', 40, 700, 0, '', ''],
'Meta Keywords' => [5, 'alpha', 40, 700, 0, '', ''],
Header => [6, 'alpha', 40, 75, 0, '', ''],
Footer => [7, 'alpha', 40, 75, 0, '', '']
CatDescription => [8, 'alpha', '40x3', 900, 0, '', ''],
);
Quote Reply
Re: Adding Category Summarys In reply to
You need to change the following line of code:

Code:
CatDescription => [8, 'alpha', '40x3', 900, 0, '', ''],

to the following (removing the comma)...

Code:
CatDescription => [8, 'alpha', '40x3', 900, 0, '', '']

Remember last fields in hashes should NOT be used.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
Anthro TECH, L.L.C
anthrotech.com
* Check Resource Center
* Search Forums
* Thinking out of the box (codes) is not only fun, but effective.


Quote Reply
Re: Adding Category Summarys In reply to
Whew... still getting errors...

I changed all files to the root of the home... I still got errors but when I run telnet i got this...

pisces:/ > /home/referra/public_html/aaaaa/upgrade.cgi
Opening output file . . .


Processing records
Done.

Database saved it as categories2.db.
Change permissions back to 755 on the data directory.

You must rename 'categories2.db' to 'categories.db before using with Links v2.
It is recommend you save the original 'categories.db' before renaming.

So it worked... I now have a categories2.db thru telnet... my browser shows 500 errors but it worked behind the seams..

anyway I kept a back up... well on to the next step...... Thanks guys..
Quote Reply
Re: Adding Category Summarys In reply to
Don't worry about the errors...if the categories2.db was created, then you are fine...Replace your original categories.db with the categories2.db file.

Welp, glad it worked.

Regards,


------------------
Eliot Lee....
Former Handle: Eliot
Anthro TECH, L.L.C
anthrotech.com
* Check Resource Center
* Search Forums
* Thinking out of the box (codes) is not only fun, but effective.


Quote Reply
Re: Adding Category Summarys In reply to
Ok Here is the code that worked for me ..
save the code to upgrade.cgi and store it in your data directory.

Change /home/referra/public/aaaaa/ to your home root full path... now what I did was open a temp folder and named it aaaaa but you can do what you want..

I had the these files in the same folder..
upgrade.cgi <-- came from the script below chmode 775
db_utils.pl <--- came from /admin/ folder chmode 777
category.def <-- came from /admin/ folder chmode 777
categories.db <-- came from /data/ folder chmode 777
and make sure your data folder or temp folder is chmode 777 also.

Code:
#!/usr/bin/perl
# -------------------------------------------
#You must EDIT YOUR category.def script BEFORE entering these variable and running this script!
$field_default = ""; #Put the default value of the new field here. Leave Blank for no default.
$new_field = "8"; #Put the new field number here.
$total_fields = "9"; #Put the last field number here.

#Change these value to match your settings
require "/home/referra/public_html/aaaaa/db_utils.pl";
require "/home/referra/public_html/aaaaa/category.def";


#You shouldn't have to edit below this line
#------------------------------------------
$nfm1 = $new_field - 1;


$ENV{'REQUEST_METHOD'} and (print "Content-type: text/plain\n\n");
open (DB, "</home/referra/public_html/aaaaa/categories.db") or print "Unable to open links database 'categories.db'. Reason: $!" and exit;
print "\tOpening output file . . .\n";
open (DBOUT, ">/home/referra/public_html/aaaaa/categories2.db") or print "Unable to open output database. Make sure data dir is chmod 777 temporarily. Reason: $!" and exit;
print "\n\n\tProcessing records\n";
while (<DB> ) {
(/^#/) and next LINE; # Skip comment Lines.
(/^\s*$/) and next LINE; # Skip blank lines.
chomp; # Remove trailing new line.
@rec_in = &split_decode($_);
# Copy ID, Title, URL, Date and Category
for $i (0 .. $nfm1) {
$rec_out[$i] = $rec_in[$i];
}
# Add New Field
$rec_out[$new_field] = "$field_default";
# Copy the rest of old categories.db to new categories2.db
for $i ($new_field .. $total_fields) {
$rec_out[$i + 1] = $rec_in[$i];
}
print DBOUT &join_encode(&array_to_hash(0, @rec_out));
}
print "\tDone.\n\n";
close DB;
close DBOUT;
print "Database saved it as categories2.db.\n";
print "Change permissions back to 755 on the data directory.\n\n";
print "You must rename 'categories2.db' to 'categories.db before using with Links v2.\n";
print "It is recommend you save the original 'categories.db' before renaming.\n\n";

now the script did error with me but it did work.. let me know if you find a better way let me know..

If you are a newbie at this and you tried all other ways email me your files and I will
do it for you... dae@alltel.net

Quote Reply
Re: Adding Category Summarys In reply to
ok I edited category.def and I rebuilt categories.bd now what?

now I can post stuff in admin. but now how do I make it show up in templates?

something like this?

<%if CatDescription%>
<center><%CatDescription%></center>
<%endif%>

Keep in mind I will place html in this CatDescription above the listings in the template links for each category...

Is there something else I have to congif? because this does not work when I rebuild..

Quote Reply
Re: Adding Category Summarys In reply to
 
Quote:
now the script did error with me but it did work.. let me know if you find a better way let me know..
If you are a newbie at this and you tried all other ways email me your files and I will do it for you... dae@alltel.net

I am confused...the codes that WORK have already been posted in the Adding Links to the Links.db FAQ...so, your point is??

Wink

Quote:
now I can post stuff in admin. but now how do I make it show up in templates?

AND

Quote:
<%if CatDescription%>
<center><%CatDescription%></center>
<%endif%>

You answered your own question...these codes should go into your category.html file.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
Anthro TECH, L.L.C
anthrotech.com
* Check Resource Center
* Search Forums
* Thinking out of the box (codes) is not only fun, but effective.


Quote Reply
Re: Adding Category Summarys In reply to
It did not work..

This is placed in category.html in templates..

<%if CatDescription%>
<center><%CatDescription%></center>
<%endif%>

There has to be more code somewhere to get this to work?

All I have done so far was place an extra field in category.def.. I placed # 8

Code:
# Definition of your database file.
%db_def = (
ID => [0, 'numer', 5, 10, 1, '', ''],
Name => [1, 'alpha', 40, 75, 1, '', '^[\w\d/_-]+$'],
Description => [2, 'alpha', '40x3', 900, 0, '', ''],
Related => [3, 'alpha', 0, 8900, 0, '', ''],
'Meta Description' => [4, 'alpha', 40, 700, 0, '', ''],
'Meta Keywords' => [5, 'alpha', 40, 700, 0, '', ''],
Header => [6, 'alpha', 40, 75, 0, '', ''],
Footer => [7, 'alpha', 40, 75, 0, '', '']
CatDescription => [8, 'alpha', '40x3', 900, 0, '', ''],
);

and I rebuilt the database categories.db

There has to be more code somewhere else..

take for example from above #5 above it is 'Meta Keywords' and in the category.html
it's <%meta_keywords%> to call it.. the letters are not caps any more..

Another Example from above #4 is 'Meta Description' and in the category.html it's
<%meta_name%> to call it.. this one is not caps any more and the name has changed?


Quote Reply
Re: Adding Category Summarys In reply to
Opps....you do need to also modify the sub build_category_pages routine in the nph-build.cgi file.

1) Replace the following codes:

Code:
local ($description, $related, $meta_name, $meta_keywords, $header, $footer, $next, $prev);

with the following codes:

Code:
local ($description, $related, $meta_name, $meta_keywords, $header, $footer, $cat_description, $next, $prev);

2) Replace the following codes:

Code:
# We set up all the variables people can use in &site_html.pl.
($description, $related, $meta_name, $meta_keywords, $header, $footer) = @{$category{$cat}}[2..7];

with the following codes:

Code:
# We set up all the variables people can use in &site_html.pl.
($description, $related, $meta_name, $meta_keywords, $header, $footer, $cat_description) = @{$category{$cat}}[2..8];

3) Then in the sub site_html_category routine define the following tag:

Code:
cat_description => $cat_description

4) Then replace the following codes in your category.html file:

Code:
<%if CatDescription%>
<center><%CatDescription%></center>
<%endif%>

with the following codes:

Code:
<%if cat_description%>
<center><%cat_description%></center>
<%endif%>

Good luck!

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
Anthro TECH, L.L.C
anthrotech.com
* Check Resource Center
* Search Forums
* Thinking out of the box (codes) is not only fun, but effective.




[This message has been edited by AnthroRules (edited May 03, 2000).]
Quote Reply
Re: Adding Category Summarys In reply to
ok I knew there was more code some where..

on the code you gave me it does not work because it has a flaw does will not let the
Admin Build pages this is your code from above

in nph-build.cgi
Code:
local ($description, $related, $meta_name, $meta_keywords, $header, $footer, $cat_description $next, $prev);

it should be
Code:
local ($description, $related, $meta_name, $meta_keywords, $header, $footer, $cat_description, $next, $prev);

you left out a comma.. with out that comma you can't build pages it will not even give you an error just a blank page.. hehe

Thanks for all your help!


[This message has been edited by thefreebiesite (edited May 03, 2000).]
Quote Reply
Re: Adding Category Summarys In reply to
Thanks for pointing out the error...I will edit my Reply.

You're welcome...

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
Anthro TECH, L.L.C
anthrotech.com
* Check Resource Center
* Search Forums
* Thinking out of the box (codes) is not only fun, but effective.