
terrill
User
Aug 7, 2002, 2:40 PM
Post #1 of 15
(10668 views)
Shortcut
|
|
Auto Subcats: Part last?
|
Can't Post
|
|
So, it's "automatic categories you want?" Well, I decided to put everthing into one post, along with directions. You only need to make these changes ONCE! After that, when you create NEW categories or SUB categories, everything is automatic! When you make an artice visible, or re-publish all your articles, everything is taken care of for you. The program makes NO changes to any of your Artman data files, it ONLY reads them. --- WHAT IT ALL DOES --- In the place where your categories are listed (We'll assum it's on the left), you visitors see: Unix Programming News If they click on a category, say Programming, or if they click on an article in the Headlines list which comes under a Programming category, they'll now see: Unix Programming --> Perl --> C News If they click on another category (not a part of Programming), the Programming group closes, and if there are subcategories for the one they just clicked, that one will expand. --- TESTED --- I've tested the code in two flavors of Linx, and Windows 2000. All of them using Apache as the server. --- REQUIREMENTS --- 1. Your Server has to allow an SSI exec command. Since you're using Artman, your chances are good it does. If it doesn't, contact your server Admin. 2. To create subcategories, use the following naming convention... the program looks for the verticle bar. Of course, you're welcome to change the program to look for something else! Category: Programming SubCat..: Programming|Perl SubCat..: Programming|C Make certain they're in order when you create them. That is, it doesn't matter if they've been created one after the other, just make sure that Programming is higher in the list than all of its subcats. If it's not, move it up using Artman's neat ability in the Category Editor. 3. Categories and subcats with spaces don't work. It has to do with the encoding of URLs sent across the Internet. Someday, if I get the time, I'll fix it. Until then, I'd stay away from spaces, or anything that gets escaped because it might be a shell-interpreted character (such as back-quotes (`) or slash (/), etc.). Since my site doesn't have this problem, don't look for me to fix it soon. --- CHANGES TO YOUR TEMPLATES --- <<<Make a backup copy of each file before changing>>> If you don't like the way things work, you just copy the files back over the changed files. Of course, I'd back those up before ya do... you might decide to give it another try, later! In your templates subdirectories, make the following changes: --- templates/headlines_bycat.html --- NOTE: there are other lines which look VERY MUCH like the following. Get the RIGHT one! UNDER the line: <!-- templatecell : row --> Change: <a href="$detail_link$">$art_name$</a> To....: <a href="$detail_link$?$cat_name$">$art_name$</a> --- templates/article/default.html --- Change: <!--#include file="$file_categories$" --> To....: <!--#exec cgi="cats.cgi" --> Delete: <!-- template include : $file_categories$ --> --- templates/headlines/default.html --- Under the line: <!-- templatecell : row --> Change: <a href="$detail_link$">$art_name$</a> To....: <a href="$detail_link$?$cat_name$">$art_name$</a> --- templates/index/default.html --- Change: <!--#include file="$file_categories$" --> To....: <!--#exec cgi="cats.cgi" --> Delete: <!-- template include : $file_categories$ --> AND Under the line: <!-- templatecell : row --> Change: <a href="$detail_link$">$art_name$</a> To....: <a href="$detail_link$?$cat_name$">$art_name$</a> --- templates/search/search_results.html --- Under the line: <!-- templatecell : row --> Change: <a href="$detail_link$">$art_name$</a> To....: <a href="$detail_link$?$cat_name$">$art_name$</a> --- THE PROGRAM --- The required CGI program is attached to this post. Place it in the directory where your files get published to. There's one line of code that you'll need to alter. It's the one after the "open" statement, and has a comment that says to change it to where your category.dat file lives. The program reads Artman's category.dat file and digests the categories from it. NOTE: there are NO statements which send anything to something other than Standard Out, so this program makes NO CHANGES to anything Artman uses... or anything else, for that matter. If it did, I doubt this message would live long on the board, since the boys and girsl at Interactive are Perl programmers! The program is attached, complete with comments. Download it and save it in your publish directory as: cats.cgi -- and -- if you're on a flavor of Unix/Linux/BSD etc, don't forget to do a chmod 755 or it won't execute. For you Windows folks, you don't have to worry about the chmod! Comments, suggestions, dollars greater than a million (nothing less) all greatly appreciated. Oh, that's the British million... with NINE zeros! Caveat: Don't expect Interactive to help you, and, if they ever change their data structure, you're on your own. They say their next Big release will support subcategories. Chances are good you'll have to make changes when they do, anyway... since they don't have such an animal now, and they can't read your mind on installs. So, you don't have much to lose. Problems or want commented code, email me at mailto:Terrill@Steal-This.com. Sorry it's such a long post, but it's not a short subject... but it IS a lazy way of doing things! Enjoy! -- Terrill -- [quote] "Evaporating expectations of quality: 1980's paradigm: If it's worth implementing once, it's worth implementing twice. 1990's paradigm: Ship the prototype! 2000's paradigm: Ship the idea!" ---Larry Rosler: http://www.perl.com/pub/a/2000/06/rosler.html [/quote]
(This post was edited by terrill on Aug 8, 2002, 9:03 PM)
|