[wp-trac] Re: [WordPress Trac] #3723: Tagging
WordPress Trac
wp-trac at lists.automattic.com
Sun Mar 25 00:39:57 GMT 2007
#3723: Tagging
-------------------------+--------------------------------------------------
Reporter: ryan | Owner: ryan
Type: enhancement | Status: new
Priority: normal | Milestone: 2.2
Component: General | Version: 2.1
Severity: normal | Resolution:
Keywords: tags |
-------------------------+--------------------------------------------------
Comment (by ryan):
I'm not particularly sold on the notion of a centralized taxonomy table,
but here's a possible design.
=== Tagging a post ===
* Comma separated tags are entered into a text box in the write post
page.
* write_post() parses $POST['tags'] and sends an array of tags (tag
names, not ids) to wp_insert_post().
* wp_insert_post() passes tags to wp_create_tags() along with a post id.
* wp_create_tags() passes the list of tags to wp_create_categories().
* wp_create_categories() creates the tags in the categories table if they
do not already exist and returns an array of IDs.
* wp_create_tags() then calls wp_set_post_tags() with the array of tag
IDs and the post ID.
* wp_set_post_tags() creates relationships between the post and the tags
in the post2tag table.
* wp_set_post_tags() increments the tagged_count field for each tag.
=== Displaying tags for a post ===
* Templates can use the_tags() and get_the_tags().
* get_the_tags() gets all tags with a relationship to the post in the
post2tag table.
=== Listing all tags ===
* Templates can use wp_list_tags() and get_tags().
* get_tags() retrieves all objects from the categories table with a
tagged_count > 0.
=== Managing categories ===
* The manage category list must filter out categories that are being used
exclusively as a tag. (link_count != 0 or count != 0) should be included.
* If a category that already exists as a tag is added via Manage
Categories, it must be brought into the list somehow even though it does
not yet have a count or link_count. A special count of -1 is used to
signify unclaimed categories that should be listed.
* When adding a new category or a category that has a tagged_count but no
count or link_count, set count and link_count to -1.
* Once the category is claimed by a post, set count to 1 and link_count
to 0. Vice versa when the category is claimed by a link.
* If an unclaimed category is claimed by a tag, set count and link_count
to 0.
* A category cannot be deleted if tagged_count is > 0. Instead, when
deleting the category the count and link_count are set to zero so that the
category is excluded from the category lists.
* If the category is later re-added via Manage Categories, count and
link_count are set to -1.
* Currently, categories can have the same name and nicename if they have
different parents. With multiple categories having the same name, a tag
needs to somehow consistently associate with one category even if that
category should be reassigned to a different parent. This association
needs to be maintained so that the same tagged_count is always
incremented.
=== Listing categories ===
* get_categories() needs to be able to exclude categories with counts of
-1 or 0 when fetching categories for the front page. It needs to exclude
only categories with counts of 0 when fetching categories for the lists in
Manage Categories and the edit post and edit link pages.
--
Ticket URL: <http://trac.wordpress.org/ticket/3723#comment:42>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list