After almost a day of editing and reorganizing, I think the blog is ready to go on-line. Many things are really chaotic, I nonetheless hope that someone might find something useful here.
I also did some minor patching of WP, making future updates will be close to impossible. Hope it will not be that bad…
To summarize today’s changes:
1. “linky” category, inspired by Diego’s blog, which was inspired by Fernando Graphicos, inspired by….
I basically followed Fernando’s suggestions, shamelessly stealing some of Diego’s CSS (not too much though). The changes I had to make included editing of all the files containing a loop “while(have_posts()…”.
Displaying hierarchical categories, instead of the flat strucutre. The change was to change “hierarchical=0″ to “hierarchical=1″ in sidebar.php.
Displaying proper categories, depending on the current user. This was a bit tricky one: Depending on the user logged in, I wanted to have the correct list of categories on the main page. The patch is one line in template-functions-category.php”:
Replacing the line (somewhere around line 290):
WHERE post_status = ‘publish’
with
WHERE ( post_status = ‘publish’”. (($user_ID)?” or (post_status=’private’ AND post_author = $user_ID)”:”") . “)
Also $user_ID has to be declared as global somewhere before.
- (FAILED) Correct counting of categories. With a hierarchical system, I wanted to have a correct number of categories, e.g. if category A (5) has two sub categories A1 (2) and A2 (7), I would like A to be displayed as (14) or (5/9), as this is the number of posts you’d see if you click on it. … or is it?
I implemented is as follows:
- storing a hash table of parent nodes while reading the categories (line 275)
- updating the total number of posts by summing it up the chain (while ($id = $parent[$id])) {} (line 295).
This would have worked, but it has a BIG problem: a post can have both categories A and A1 set and thus would be counted twice. To avoid this, one would have to change the entire logic of a query: A single SQL query would have to be replaced by 2*n queries (for each category, querying the child categories -> using get_category_children() from classes.php) and then querying the number of posts in each of the categories. While it would have been feasible, I thought it’s not worth it and I gave up.