Ticket #4015 (closed defect: fixed)

Opened 1 year ago

Last modified 11 months ago

Post and link category confusion

Reported by: donncha Assigned to: ryan
Priority: normal Milestone: 2.3
Component: Administration Version: 2.2
Severity: normal Keywords: developer-feedback
Cc:

Description

If a category has links added to it but is a parent of categories with posts, or is a parent of categories you want to see in the Write page then none of the child categories will show. See the SQL in wp-admin/admin-functions.php:return_categories_list();

Fix? Display all categories on the Write page regardless of link_count value.

Attachments

4015.diff (0.7 kB) - added by rob1n on 03/24/07 21:20:02.
cat_scope.diff (5.0 kB) - added by Tjworld on 05/04/07 05:15:05.
cat_scope patch for 2.1.3

Change History

03/22/07 14:20:27 changed by foolswisdom

  • version set to 2.2.

(follow-up: ↓ 8 ) 03/22/07 17:34:13 changed by Otto42

+1

In fact, we should consider displaying all categories on both the write post/page as well as on the bookmarks add screen. There is really no reason to prevent a category from containing both posts and links, and it would give potential to some interesting mashups and plugins and such.

Example: I think it would be neat if my added Bookmarks could be shoved into my posts loop, so that links I add could show up as one-liners between posts. Then I could categorize them and such. Kind of like asides, but with just links, no real post info required.

As it stands now, blocking categories with links from appearing on the post screen and blocking categories with posts from appearing on the links screen causes more confusion than it prevents.

There will, of course, be complaining as people with loads of categories suddenly see all them in places they were not expecting, but that will be limited.

03/22/07 22:37:05 changed by ryan

We used to do it that way but the complaining was quite loud. I personally would prefer to eliminate the count checks and just show everything.

03/24/07 21:20:02 changed by rob1n

  • attachment 4015.diff added.

03/24/07 21:20:18 changed by rob1n

  • owner changed from anonymous to rob1n.
  • status changed from new to assigned.

Patch drops the count checks.

03/24/07 21:21:02 changed by rob1n

  • keywords set to has-patch.

03/25/07 17:04:43 changed by rob1n

  • owner changed from rob1n to ryan.
  • status changed from assigned to new.

Reassigning to ryan to [maybe] commit.

03/29/07 01:38:45 changed by ryan

Let's hold off for now. This change will create flames.

(in reply to: ↑ 2 ) 03/29/07 02:26:04 changed by foolswisdom

  • priority changed from high to normal.
  • milestone changed from 2.2 to 2.3.

Replying to Otto42:

There is really no reason to prevent a category from containing both posts and links

The reason it can be a bad idea is an overwhelming list. This is a symptom of the current UI, and maybe also a symptom of not having tags -- we will see.

With a single catalog, with this UI, intuitively you would want: Created on post page -> always display in post catalog, not in blogroll if no links Created on blogroll page -> always display in blogroll, not in post page if no posts Created in category management -> always display in both

05/03/07 11:43:29 changed by Tjworld

I’ve just spent the best part of a morning trying to work out why 60 categories weren’t showing up when posting/editing, after assigning them to links.

I hacked the code and found the SQL clause in return_categories_list() causing the issue. It makes no sense to me, definitely counter-intuitive and even illogical.

As a solution, how about adding an integer field "cat_scope" to wp_categories?

"cat_scope" would have the values: 0 = Both, 1 = Posts, 2 = Links.

In the "Edit Category" form add a radio-button field "Scope: * Both * Posts * Links"

Then modify the SQL queries in return_categories_list() and return_link_categories_list() to use the new field as the discriminator instead of the AND/OR logic.

05/03/07 15:57:47 changed by karmadude

I had figured this solutions back in feb, and I have been using it on my blog, and it works well. It allows the same category to be used for posts and links, and very useful when you want to show post category specific links.

05/03/07 19:01:44 changed by Otto42

karmadude: I made the same change to my core code just after 2.1 came out too, and have continued to make the change every upgrade. It's a heck of a lot nicer to have all the categories available for both posts and links, even if I don't use them. All the user confusion goes away when you can see the categories as one unit.

All I did was to change the return statements in return_categories_list() and return_link_categories_list() to both do this:

return $wpdb->get_col( "SELECT cat_ID FROM $wpdb->categories WHERE category_parent = $parent ORDER BY link_count DESC" );

Completely eliminate the count checks and allow all categories to show everywhere. It's so much simpler and easier to use. Create a new category and it shows up right away. Categories don't disappear from links just because you make posts to them and vice versa. Things work the way that the user expects them to work.

I'll continue making this change to my own code. And if we're not going to fix the broken core categories code to allow this, then we should at least add hooks so that I can turn this sort of behavior into a plugin instead of a core hack.

05/04/07 05:15:05 changed by Tjworld

  • attachment cat_scope.diff added.

cat_scope patch for 2.1.3

(follow-up: ↓ 14 ) 05/04/07 05:15:58 changed by Tjworld

A follow-up to my suggestion of adding the "cat_scope" to wp_categories table, and allowing each category to be set to belong to one of 'Both', 'Post', 'Link'.

I've tested this and it works nicely. It had the added benefit that when a parent category is, say, 'Link' only, all that categories children are hidden from the Post Category list, so the heirachy is maintained.

I've attached a patch generated against WordPress 2.1.3

05/04/07 05:23:26 changed by Tjworld

cat_scope:

The WordPress database will need the field adding. From a terminal do:

$ mysql -u <username> -p <database> Enter password: *******

mysql> ALTER TABLE wp_categories ADD COLUMN cat_scope INT default 0; mysql> quit

** This assumes your tables are prefixed "wp_". Change the line above if using a different prefix.

(in reply to: ↑ 12 ) 05/04/07 13:54:54 changed by foolswisdom

  • keywords changed from has-patch to developer-feedback.

Replying to Tjworld:

A follow-up to my suggestion of adding the "cat_scope" to wp_categories table, and allowing each category to be set to belong to one of 'Both', 'Post', 'Link'.

Fixing this bug likely depends on #4189: Taxonomy Schema and API

05/04/07 16:04:40 changed by Otto42

The category stuff is changing into the new combined taxonomy stuff, most likely, so I would not suggest that any work be done on this code since it's probably all going away.

Still, I would like those working on the taxonomy to consider eliminating the separation between link and post categories in the process of their changes. This separation adds way more confusion than it can ever produce.

(follow-up: ↓ 17 ) 09/01/07 03:54:02 changed by ryan

  • status changed from new to closed.
  • resolution set to fixed.

Full separation seemed to be the popular choice, so there is now separate category and link category management. Resolving as fixed.

(in reply to: ↑ 16 ) 09/01/07 04:13:14 changed by karmadude

Replying to ryan:

Full separation seemed to be the popular choice, so there is now separate category and link category management. Resolving as fixed.

Can the same category be used for both posts and links? For example if I have a category Videos, and I want to post a youtube video or a link to youtube.com

In this scenario do I have to have two videos categories; One for links and another for posts? If this is the case, then the issue of this ticket still exists.

09/01/07 06:50:24 changed by karmadude

I just checked 2.3 Beta 1, and looks like link and post categories have been separated out again. For those who modified the code and have been using the same category for links and posts, upgrading to 2.3 might duplicate all your categories and break all the functionality which expects the categories to be same.

This is going to be a lot harder than the previous version to have same categories for both links and posts because of the new taxonomy tables. But there is a little trick that might work: let's say we have a post category called video, if an extra entry is made to the term_taxonomy table for the video category, and set taxonomy to link_category, it might just work. I will have to try this out.

The upgrade script will have to be modified to include this extra step, otherwise, it's going to wreck havoc!

It's just lame when people conveniently drop obvious functionality for the sake of popularity. I mean come on, you added tags to posts, but no tags for links!! At least that would have provided the commonality some of us are looking for with categories.

(follow-up: ↓ 20 ) 09/02/07 18:40:13 changed by foolswisdom

karmadude, thank you for participating in WordPress! You know your approach is on unstable ground when you write "for those who modified the code".

(in reply to: ↑ 19 ) 09/02/07 19:24:45 changed by karmadude

Replying to foolswisdom:

karmadude, thank you for participating in WordPress! You know your approach is on unstable ground when you write "for those who modified the code".

Well foolswidom, reality is some people do modify Wordpress for certain functionality! Some of the comments in the post(which is conveniently ignored), justifies that. If you want to do something about stable footing see #4883

Thanks, and an enhancement is much appreciated, and will help of some of us get on stable footing!