Opened 19 years ago
Closed 18 years ago
#2499 closed defect (bug) (fixed)
Rework Link Categories
Reported by: | ryan | Owned by: | ryan |
---|---|---|---|
Milestone: | 2.1 | Priority: | low |
Severity: | normal | Version: | 2.0.1 |
Component: | Administration | Keywords: | links has-patch |
Focuses: | Cc: |
Description
Link categories have a number of options associated with them that could be blog level options. Also, links could reuse the regular post categories for their purposes instead of having separate link-specific categories. Let's get rid of the linkcategories table, move the link category options into the options table and apply them uniformly to all links, and add a link2cat table for assocating links to categories. This allows us to get rid of the busy link-categories.php page entirely and reuse all of the post category stuff. Categories that have no links associated with them will be ignored when listing links by category.
Attachments (12)
Change History (52)
#2
@
19 years ago
So, I have to count the number of links in a category to be able to hide empty categories. The counts need to be cached to the DB like we do with the post counts. Another field in the categories table, I guess.
#3
@
19 years ago
Anyone use that auto toggle stuff? I'm not even sure what it is, and it looks like it is partially broken in 2.0.x.
#4
@
19 years ago
Seems broken.
It would work like this: if a new link was added to that category, all other links in that category wouuld switch to being invisible. The reason you can't just say "limit 1" and have it work the same way is that there is no way to sort links by date added (because there is no date field for links), so this toggle was a way to rig it to work, but only for one post.
I actually used it for a client about a year ago. She wanted a rotating "link of the week feature" at the top of her sidebar. I used the toggle feature and whenever she added a new link, the old one would go invisible.
I think if we add a date field to the links, there will be no need for this toggle, as you'll just be able to limit it to showing 1 link and sort by date DESC.
Actually, it would be really cool if the links had full date functionality... one could use it to run their own linklog in-house without resorting to hacks to get WP posts to do it. I may have submitted a ticket for this way back in the day.
#5
@
19 years ago
Yes, timestamps seem better than auto toggling. I've purged the auto toggling for now.
#6
@
19 years ago
- Consider adding category_type field to wp_categories (links, posts, pages)
- Does there need to be a default Category for Links designation just like the default Post Category in Options-Writing?
- Visible should be set to Yes (now nothing is checked).
- Error when displaying site with default theme where sidebar.php uses get_links_list (did upgrade.php from 2.0.1 alpha1)
Warning: date() [function.date]: Windows does not support dates prior to midnight (00:00:00), January 1, 1970 in C:\xampp\htdocs\wp201test\wp-includes\links.php on line 162
- No links display on site after doing install.php--wp_link2cat has no data
- Maybe I applied the patch wrong, but where is wp-admin/link.php?
- Regarding timestamps, the wp_links field, link_updated, is all zeros in several blogs (1.5.2 and 2.0.1) I checked.
#7
@
19 years ago
- Maybe. I kinda like having categories shared. But, we'll have to see how usable that is in practice.
- I plan to add a default link category dropdown to Options->Links along with the options for link sorting, etc.
- Yes, I'll fix that.
- That's the typical error that happens when trying to get the permalink of a non-existent post. Weird that it is happening here. I don't see this with the default theme.
- I'll fix that.
- It's in the patch. Maybe patch isn't creating the file.
- I think you have to have link updating turned on. See Options-Misc (I'll probably move that option to Options-Link).
#8
@
19 years ago
- Default link category in Options->Writing next to default post category.
- Fixed.
- Couldn't reproduce.
- Fixed.
#9
@
19 years ago
Did install.php with links_category.4.diff installed
- wp_linkcategories table shouldn't be created
- When Viewing Site, this in sidebar using default theme caused by get_links_list I believe:
WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near at line 1]
SELECT wp_links.link_id, link_url, link_name, link_image, link_target, link_description, link_rating, link_rel , IF (DATE_ADD(link_updated, INTERVAL 120 MINUTE) >= NOW(), 1,0) as recently_updated FROM wp_links WHERE link_visible = 'Y' ORDER BY link_ ASC LIMIT
- This error page when either to click on Edit to edit the link. Also get same error page when clicking on Add Link:
Object not found!
The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error.
If you think this is a server error, please contact the webmaster.
Error 404
localhost
02/23/06 20:32:40
Apache/2.0.54 (Win32) mod_ssl/2.0.54 OpenSSL/0.9.7g PHP/5.0.4
- Visible is still not set when Adding a Link
#10
@
19 years ago
- I'm leaving linkcategories around for now. Disaster recovery. :-)
- That query is an old one. The query is different in the latest patch.
- Maybe the patch didn't apply fully.
- Hmm, works for me.
New patch coming up.
#12
@
19 years ago
New patch adds two new fields to the categories table. link_count counts the number of links assigned to a category. links_visible will toggle visibility for all links in that category, in case you want to hide your pron links. links_visible isn't fully implemented yet. TODO.
The "Link Categories" page is back. It's the same as Manage->Categories but shows the # of links per cat and the default link cat. link-categories.php and categories.php need to have the common bits factored out into category.php. That's not a big deal though since all of the heavy lifting is done in the wp_*_category functions that are used by both files.
#13
@
19 years ago
Link delete fixed. link2cat is updated as is link_count. Our AJAX list manipulation was calling the wrong thing.
#14
@
19 years ago
After installing link_categories.2.diff and doing a install.php, looks good except:
- Visible still not set in Add Link (wp-admin/link-add.php).
- Deleting Link didn't delete it from link2cat table and looks like it didn't updated the link_count in wp_categories.
- I've got two Link Categories (Blogroll and Mylinkcat) and 10 Links. The Blogroll Category has 9 Links, the other 2 Links (one of the Links is assigned both Categories). When I View the site, the Blogroll Category displays this error 10 times then displays 10 (should be nine) Links. Then Mylinkcat displays, followed the same error, 10 times, followed by 10 (should be two) Links:
Warning: date() [function.date]: Windows does not support dates prior to midnight (00:00:00), January 1, 1970 in C:\xampp\htdocs\wp16\wp-includes\links.php on line 161
Otherwise, couldn't duplicate any of the previous issues reported before.
Nice work Ryan!
Darn, see you added another patch so ignore number 2 above.
#16
@
19 years ago
After installing link_categories.4.diff and doing a install.php;
- Fresh install, wp_categories table, the Blogroll category should have a link_count=7 not category_count=1
- Having the same Categories in Manage->Categories, and Links-Link Categories is interesting ;)
- wp-admin/link-categories.php has this message but the default Link Category is Blogroll:
Deleting a category does not delete posts from that category, it will just set them back to the default category Uncategorized.
should read
Deleting a category does not delete LINKS from that category, it will just set them back to the default category Blogroll.
- Deleting a Link Category kind of hangs with a message, Processing Data..., displayed at the bottom of the Categories box (wp-admin/link-categories.php). Never does do the delete.
#17
@
19 years ago
- 1. Fixed
- 2. Well... :-)
- 3. Fixed.
- 4. Not sure about that one. I think I got it. Works for me.
#18
@
19 years ago
After installing link_categories.4.diff and doing a install.php;
- Deleting a Link Category assigns Links to the "Uncategorized" Category rather than default "Blogroll". Add a new Link Category (Mylinkcat), edit one of the existing Links and check both Blogroll and Mylinkcat and save it. Then delete the Mylinkcat Category. Table wp_link2cat shows the wrong Category for that link. Not to sure link_count in wp_categories is getting updated correctly there either.
- When trying to delete a Category in Manage->Categories, where that Category is not assigned to any Posts, but is assigned to a Link, it displays the message "Processing Data...". This is probably what I saw last night when I descibed it as "hanging". It should display a message saying "You can't delete this Category because it is assigned to one or more Links." The same thing happens in Links->Link Categories when you delete a Category that is not assigned to any Links but is assigned to Posts. Or course, there is the possiblility that if you delete a Category in either place, both the Posts and the Links should be assigned their corresponding "default" Category, but in that case the warning message should note that both Posts AND Links will be assigned their respective default Category.
- You should not be allowed to delete a Category in Links->Link Categories when it is used as the "default" Category for Posts even though it is not assigned to any Posts. This probably is working okay, but again when trying to delete a Category in this scenario it just displays the "Processing Data..." data message. Is a different message warranted saying that Category is designated as a "default" Category on the Options->Writing page?
- Still wonder how people with many Categories are going to react to seeing what they consider Link Categories when writing Posts?
- While digging in this, is it proper to consider assigning Categories to Pages?
#19
@
19 years ago
Okay. This patch goes back to having a unified category manager. It shows the number of posts and number of links per category and updates the delete messages to note that both links and posts will be reassigned to their respective defaults.
- I think I got this sorted.
- I still need to look at this.
- The default link and post cats are now designated as defaults and protected from deletion.
- The new unified category manager makes it clearer that categories are a shared resource. We'll see how that flies.
- Matt and I have kicked the idea around but are still siding on leaving categories off of pages unless a persuasive reason to have them pops up. Categories on pages are useful when trying to do Wiki-like things, but WP is not a Wiki out of the box.
#20
@
19 years ago
Also, the latest patch uses the term Bookmarks instead of Links. Links is a rather overloaded term in WP, so lets experiment with other naming. I considered Favorites since IE made it so common, but in the context of a weblog links are not the only things that can be favored. So, I'm trying out Bookmarks for now. Another possibility is Blogroll/Blog Links. The terminology change is not complete. I'm just trying it out in a few places to see how it looks. If we add Firefox bookmark sync or the like, a terminology change looks more attractive.
#21
@
19 years ago
After installing link_categories.6.diff and doing a new install.php;
- In options-writing.php change "Default link category" to "Default Bookmark Category". Of course I vote for cap letters on Bookmark and Category everywhere ;)
- In options-misc.php change "Track Links’ Update Times" to "Track Bookmarks’ Update Times"
- In link-import.php change the title "Import your blogroll from another system" change to "Import your Bookmarks from another system". Change "Now select a category you want to put these links in." to "Now select a category you want to put these Bookmarks in." And what do you want to do with this text "If a program or website you use allows you to export your links or subscriptions as OPML you may import them here."?
- In categories.php change "Deleting a category does not delete the posts and links in that category. Instead, posts in the deleted category are set to the category Uncategorized and links are set to Blogroll" to "Deleting a category does not delete the posts and Bookmarks in that Category. Instead, posts in the deleted Category are set to the Category Uncategorized and Bookmarks are set to Blogroll."
- In link-manager.php change "Manage Multiple Links:" to "Manage Multiple Bookmarks:" and "Use the checkboxes on the right to select multiple links and choose an action below:" to "Use the checkboxes on the right to select multiple Bookmarks and choose an action below:"
- In link-add.php change "Add Link" button to "Add Bookmark"
- In link-manager.php in the Order by pull down box should "Link ID" be "Bookmark ID"?
- In link-manager.php when you delete a Bookmark the confirmation message refers to link not Bookmark.
- Just in case you thought there was no meat in this list, in link-add.php when I added a Category called Mycat, unchecked Blogroll, checked Mycat, then added a Bookmark, ts put that Bookmark in the "Uncategorized" Category. The Category "Mycat" did get created properly.
- In categories.php, deleting a Category with one Bookmark using that Category, the link_id in wp_link2cat got set to zero (0) so of course in wp-admin/link-manager.php that Bookmark has nothing under the Category column.
- In categories.php the delete confirmation message refers to "links" but should be "Bookmarks".
- How about changing the the table name wp_link2cat to wp_bookmark2cat and wp_links to wp_bookmarks. And how about some of those field names like link_count? I'm sure this will go over big!
#22
@
19 years ago
continuing from before:
- Assigned all eight Bookmarks to four Categories. View Site, and each of the four Categories shows all eight of Bookmarks.
- In link-manager.php separate each Bookmark's Categories with commas (it does that in edit.php).
- In link-manager.php, in the "Show bookmarks in category:" pull-down, select the "Uncategoried" Category where I have but one Bookmark, and this error happens when clicking Show:
WordPress database error: [Column 'link_id' in order clause is ambiguous]
SELECT * , IF (DATE_ADD(link_updated, INTERVAL 120 MINUTE) >= NOW(), 1,0) as recently_updated FROM wp_links LEFT JOIN wp_link2cat ON (wp_links.link_id = wp_link2cat.link_id) WHERE 1=1 AND category_id = 1 ORDER BY link_id ASC
- In link-manager.php, every "Order by:" choice should be a column on that screen. Either delete them from the the Order by: pull-down or add those columns (e.g. Owner and Rating).
- In link-manager.php, Toggle Visibility in the Manage Multiple Links section doesn't work
#23
@
19 years ago
1 - 11. Done
- Renaming the links table will cause consternation. I think we should leave 'links' in the guts.
- That's a feature. :-)
14 - 17. In the works.
#24
@
19 years ago
Redescribing 13 above--assigned 1 Bookmark to Category 1, 1 Bookmark to Category 2, 1 Bookmark to Category 3, and 6 Bookmarks to Category 4, but all 8 Bookmarks get listed under each Category. That is a nice feature ;-)
#27
@
19 years ago
After installing link_categories.10.diff and doing a new install.php;
- In link-manager.php separate each Bookmark's Categories with commas (it does that in edit.php) (was 14 before).
- In link-import.php, after the import is done it says "Inserted 50 links into category 1. All done! Go manage those links." Change the two references from links to Bookmarks.
- In link-import.php, it also says it imported into category 1, but it didn't write any records to wp_link2cat. It also didn't update the link_count in wp_categories.
- In categories.php the delete confirmation message refers to "links" but should be "Bookmarks".
- In categories.php, deleting a Category with one Bookmark updates wp_link2cat properly but not the link_count in wp_categories.
- If you have a Bookmark in two Categories (MyCat1 and MyCat2), and neither Category is the default Bookmark Category, if you delete the Category MyCat1, that Bookmark is left assigned to MyCat2 AND gets newly assigned the default (Blogroll) Category. Just not sure if that Bookmark should get assigned that default Category... Regardless, even though it does update wp_link2cat, it doesn't update the link_count in wp_categories.
- In categories.php, if you have both a Bookmark and a POST assigned to a Category that is not designated as a default, when you delete the Category it updates the link_count correctly in wp_categories but the category_count doesn't get updated (wp_post2cat gets updated okay though).
- Consider dividing the Bookmarks menu choices up and put them under the Write, Manage, and Import menus?
#28
@
19 years ago
Oops, regarding 3 above, it should say it Inserted 50 Bookmarks into Category 2 (not Category 1). Actually displaying the correct Category Name rather than the ID would be nice ;-)
@
19 years ago
Better category deletion behavior, bulk delete, remove bulk visibility toggle, remove reassign
#29
@
19 years ago
Okay. Patch 11 adds a bulk delete option but removes bulk reassignment and bulk visibility toggle. Link ownership is going away entirely and soon visibility can be controlled on a per category level. I added links_private and posts_private to the category table in anticipation of private categories.
- On the todo.
- and 3. I made some changes here but haven't tested yet. I'll probably overhaul the importer soon.
- Fixed.
- Fixed.
- This has long been an issue with posts. Assignment to the default category should no longer happen if the post or bookmark has more than one category assigned to it.
- Fixed.
- Actually, Manage is getting pretty big. We might move things in Manage up a level so that you can get at more things with one click. We can tackle that in another bug.
#30
@
19 years ago
After installing link_categories.11.diff and doing a new install.php;
- This in the address bar, http://localhost/wp21/wp-admin/link.php?link_id=6&action=edit, after adding two Categories 'on the fly' -- Mycat1,Mycat2. It put those Categories in the list of available Categories and also displayed 12 instances of "undefined". Strange order there also. But it didn't update wp_categories or wp_link2cat. Problem happens adding even one Category there. Does the same thing writing a post.
- In categories.php it allows you to Add a Category but the tables never get written though it does splash the message "Category added". This is left in the address bar: http://localhost/wp21/wp-admin/categories.php?message=1#addcat
- In link-manager.php, the box at the bottom says "Delete Checked Links". Should be "Delete Checked Bookmarks".
- In wp-admin/link-manager.php?deleted=5 the splash message say "! 5 comments deleted" should be "! 5 Bookmarks deleted". Also, the box at the bottom then says "Deleted Checked Links" should be "Deleted Checked Bookmarks".
- Imported bookmarks got put into Category ID 1 (Uncategorized0 even though told it to put in Category 2 (Blogroll). Actually it suggested Blogroll as the import Category so I never changed it.
- Even doing a bulk delete of 50 Bookmarks, then doing a new "Order by:" and clicking the Show button, it still shows this in the address bar: http://localhost/wp21/wp-admin/link-manager.php?deleted=50 and again displays the splash message that "! 50 comments deleted".
- Starting with two Categories--in categories.php, after deleting a Category with one Bookmark it redislays the first and only Category, but shows the wrong Link Count. Doing a browser refresh caused it to display correctly.
#31
@
19 years ago
continued:
- This error when doing upgrade.php from a 1.5.2 database;
WordPress database error: [Unknown column 'links_visible' in 'field list'] INSERT INTO wp_categories (cat_ID, cat_name, category_nicename, category_description, category_parent, links_visible) VALUES ('0', 'Blogroll delivered with WordPress', 'blogroll-delivered-with-wordpress', , '0', )
#32
@
19 years ago
- and 2. I can't reproduce, but I think its failing for you because of 8.
- Fixed.
- Fixed.
- Fixed, I think.
- Yeah, that message is going to stick around as long as deleted= is in the URI.
- The AJAX removes the deleted bookmark from the list but doesn't refresh the rest of the list. Don't know what to do about that.
- Fixed. Should fix 1. and 2. as well.
#34
@
19 years ago
Hence categories are unified now, I think we should delete the "linkcategories"-table on upgrades. On fresh installs it even shouldn't be created.
#35
@
19 years ago
[3598] removes linkcategories from the schema so that it is not created for fresh installs. Let's hold off on dropping it during upgrades until we're happy with the new design and code.
#37
@
19 years ago
I like the link categories being there, but it would be more powerful if it were a tree structure like the post categories. And then if a link category tree can be associated with a post category or categories, that would be perfect. The reason I am seeking this feature, is because on my blog (http://www.counterjumper.com), I have context sensitive links, and I want the links to change according to the category of post one is viewing.
I kind of achive this with the current version of wordpress, but it would be more powerful and easier to implement, if wordress supported a category tree for links, and then having the ability to associate that with a post category. I also feel we should not get rid of the link categories, it is important to keep it seperate.
Here is the get_linkobjectsin method I have added to links.php to get links from multiple link categories.
function get_linkobjectsin($category = "-1", $orderby = 'name', $limit = -1) { global $wpdb; $sql = "SELECT * FROM $wpdb->links WHERE link_visible = 'Y'"; if ($category != -1) { $sql .= " AND link_category IN ($category) "; } if ($orderby == '') $orderby = 'id'; if (substr($orderby,0,1) == '_') { $direction = ' DESC'; $orderby = substr($orderby,1); } if (strcasecmp('rand',$orderby) == 0) { $orderby = 'rand()'; } else { $orderby = " link_" . $orderby; } $sql .= ' ORDER BY ' . $orderby; $sql .= $direction; /* The next 2 lines implement LIMIT TO processing */ if ($limit != -1) $sql .= " LIMIT $limit"; $results = $wpdb->get_results($sql); if ($results) { foreach ($results as $result) { $result->link_url = $result->link_url; $result->link_name = $result->link_name; $result->link_description = $result->link_description; $result->link_notes = $result->link_notes; $newresults[] = $result; } } return $newresults; }
#39
@
18 years ago
Whilest reviewing the link / post categories stuff in relation to a recent testers post (http://comox.textdrive.com/pipermail/wp-testers/2006-September/002838.html)
- Create Bookmark doesn't only lists categories which already contain links - this can exclude the default bookmark category if it has no links in it.
Also (dunno if it's in your patch) when listing posts by category, even if you have it set to display empty categories, it should maybe skip categories that are only filled with links.