Hi, I'm going to fix this myself but thought I'd post it in case anyone else has noticed or fixed the problem. When you list all contacts, the query does this: ".. WHERE co.category = ca.cid". This seems to be wrong, in the contact_directory the category field is the index of the categories in alphabetical order rather than the cid order that they were entered in. The result is the listed categories are all wrong on the "contacts list" page, but are fine on individual contact view page and other pages.

Fix: need to call _contact_dir_get_select_category to translate from select box order (alphabetical) to "cid order" (the order in which the categories were created.)

Comments

chris_calef’s picture

Whoops, bug may not be what I first thought... curious as to whether anyone else has experienced this behavior. On further analysis, it appears that form_select() in common.inc may be my problem. As far as I can tell, it is supposed to get an associative array with keys/values that in this case should represent cid/category name. Instead of reading the keys, it always assigns 0,1,2,etc., so instead of accurate cid in my contact_directory table, I get the order it was listed in in the select box.

Will post an update when I get to the bottom of it.

chris_calef’s picture

Fixed! Source of the problem was the use of array_merge(), which wipes out numerical keys and renumbers them. I replaced the following:

[code]return array_merge($categories, _contact_dir_get_categories());[/code]

with this:

[code]
$categories2 = _contact_dir_get_categories();
$categories = $categories + $categories2;
return $categories;[/code]

chris_calef’s picture

whoops, sorry about the [code] blocks, thought that would work here. :-P

microwav’s picture

newbie here,

if this is the same error that causes contact directory not to list contacts and not to yield any search results, then i have the same problem. i'll try the code swap.

microwav’s picture

negative. source code swap did not solve problem.

anyone else have suggestions?

gtoddv’s picture

That code fixed it for me. But to be clear, here was the problem I was having.

When creating a contact, often the category you picked (eg cat. B) didn't save, it would default to the first category (eg cat A).

When searching, you would get the opposite category (eg cat A) than what you searched (eg cat B). I suspect though that the system was defaulting to the first category entered (cat A) and I was always searching for the other category (cat B).

Anyway, it all seems to be working now. However I will be creating a few more categories over the cooming weeks. I will repost if more anomilies occur.

gtoddv