Gossamer Forum
Home : Products : Gossamer Links : PHP Front End :

Re: [Dan Kaplan] showing 'father' category in related@ links

Quote Reply
Re: [Dan Kaplan] showing 'father' category in related@ links In reply to
I came up with a solution to part 1 of 2 (I was inspired by qango in the Discussion forum looking into similar issues) -- getting the related titles to indicate what top level category they are in. In page.inc.php's generate_category_page(), in the Yahoo subcat section (I didn't bother with the non-integrated section) I changed:

Code:
$sth = $DB->query("SELECT RelatedID, RelationName FROM
${PREFIX}CatRelations WHERE CategoryID = '" . $category['ID'] . "'");

to:

Code:
$sth = $DB->query("SELECT r.RelatedID, r.RelationName, c.Full_Name
FROM ${PREFIX}CatRelations r, ${PREFIX}Category c WHERE r.CategoryID =
'" . $category['ID'] . "' AND r.RelatedID = c.ID");

and:

Code:
$rel[$relate[0]] = isset($relate[1]) ? $relate[1] : '';

to:

Code:
$split = explode("/", $relate[2]);
if (count($split) < 3) {
$rel[$relate[0]] = $relate[2]; // 2 level subdir, no need to abbreviate
} else {
// 3+ level subdir, show just first and last cat's
$rel[$relate[0]] = $split[0] ."/.../". $split[count($split)-1];
}

Here's an example page:

http://run-down.com/.../index.php?cat_id=18

The remaining problem is how to sort the related categories alphabetically by the Full_Name field (that example page looks correct, but it's coincidental to both the top level and related category names fitting in alphabetically). That looks to be a bit challenging, based on:

Code:
$order_by = 'ORDER BY ' . $CFG['build_category_sort'];

I'm thinking some post-query sorting will be necessary, as $CFG['build_category_sort'] looks to be used for both the regular subcategories (Name) and related subcategories (Full_Name).

Dan
Subject Author Views Date
Thread showing 'father' category in related@ links Dan Kaplan 4034 Jul 3, 2002, 11:38 AM
Thread Re: [Dan Kaplan] showing 'father' category in related@ links
Dan Kaplan 3961 Jul 3, 2002, 12:59 PM
Post Re: [Dan Kaplan] showing 'father' category in related@ links
Dan Kaplan 3948 Jul 3, 2002, 3:37 PM
Thread Re: [Dan Kaplan] showing 'father' category in related@ links
brewt 3950 Jul 4, 2002, 12:17 AM
Post Re: [brewt] showing 'father' category in related@ links
Dan Kaplan 3944 Jul 4, 2002, 8:28 AM
Thread Re: [Dan Kaplan] showing 'father' category in related@ links
Dan Kaplan 3891 Aug 12, 2002, 10:44 AM
Post Re: [Dan Kaplan] showing 'father' category in related@ links
Dan Kaplan 3862 Aug 12, 2002, 10:40 PM