The MU forums have moved to WordPress.org

1 2 3

Global Categories for Wordpress MU (how I did it and my "plugin") (75 posts)

  1. deltakid
    Member
    Posted 17 years ago #

    Hi,
    as the demand for this feature seems to be quiete high I made some changes in the last hours to my own little plugin for global categories and documented how to implement it.

    It works on September Nightlies and Wordpress MU 1.0 and shouldn't take anyone with a bit of experience in PHP longer than 20 Minutes to implement.

    Check the global categories fix over here http://www.uhdinger.com/global-categories-wpmu/

    It works for me and should work for everyone but please use it at your own risk and let me know how I can make it better or fix some bugs. I also really want to get mod_rewrite working by the way see this thread for more info http://mu.wordpress.org/forums/topic.php?id=2379&replies=2

    I have a couple of ideas to add some little features but got to go to a wedding this weekend. I will be back on Monday.

    Thx, hope it helps.

  2. boetter
    Member
    Posted 17 years ago #

    Good work, really looking forward to seeing this develop much further. How many blogs have this been tested on?

    I just sent you a little money to keep the development going :-)

  3. deltakid
    Member
    Posted 17 years ago #

    Thx a lot! I have tested it on 2 blogs so far and a new 1.0 installation yesterday. I come back home tonight and will add some more little features to it.

  4. suleiman
    Member
    Posted 17 years ago #

    it looks great deltakid, will be donating later on this evening.

    I need to let you know that I'm really interested in getting a page off the global categories where the tags are displayed at the top instead of the bottom, and only the tags but not the posts are visible.

    In addition, does this let users select from predefined global categories that are predefined? If so where are they defined and how does one go about setting them?

    I really truly truly really have nothing but praises (and dollars) to give to you for this effort. And like my colleague boetter, I'm looking forward to seeing the future development of this little gem. :)

  5. deltakid
    Member
    Posted 17 years ago #

    If you just use the tag / category cloud function before the recent posts function you will display the tags on top and the posts below.

    gc_category_cloud();
    gc_recent_posts(20, '');

    You can also just edit the gc_category_cloud function that it displays the tags on one page and the posts are shown on another.

  6. deltakid
    Member
    Posted 17 years ago #

    Currently all categories and all posts are included in the wp_global_posts table. If a couple of people tell me that they like a certain feature I will implement it.

    Right now I'm still bug hunting but I didnt find any so far. I updated the core file edits text though to add a more precise check for blog_id and post_id when people edit or delete a post.

  7. suleiman
    Member
    Posted 17 years ago #

    How and where would I go about running the following command on my MySQL Table?

    CREATE TABLE wp_global_posts (
    ID bigint(20) NOT NULL auto_increment,
    blog_id bigint(20) NOT NULL default '0',
    title varchar(230) NOT NULL default '',
    category varchar(230) NOT NULL default '',
    timestamp datetime NOT NULL default '0000-00-00 00:00:00',
    post_id bigint(20) NOT NULL default '0',
    KEY ID (ID)
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;

    I'm running phpMyAdmin.

    EDIT: For those of you unfamiliar with phpMyAdmin, I found you can run this command by logging into phpMyAdmin (Cpanel-->MySql Databases-->phpMyAdmin is at the bottom) Then select your wpmu database from the left, then selecting the SQL tab and then pasting the contents into the box and running the query.

  8. suleiman
    Member
    Posted 17 years ago #

    Deltakid it WORKS! And I've just donated. :)

    I just have one request:

    1) Ideally I would like for the tags to appear on one page, and then upon clicking on a tag have the results appear on a new page.

    I absolutely positively love it dude...thanks so so much!

    FYI anyone wanting to check it out on my site: http://www.hadithuna.com/tags/

  9. suleiman
    Member
    Posted 17 years ago #

    Deltakid, I just thought of this but now that all the posts are going into a single database, how easy/hard would it be to have the search function on the main blog search all the posts on the site?

    Also found my first error:

    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 'an', '2006-09-14 14:29:53', '84')' at line 4]
INSERT IGNORE INTO wp_global_posts (ID, blog_id, title, category, timestamp, post_id) VALUES ('', 19, '\'Ethical Sayings of the Prophet Muhammad\'', 'Qur'an', '2006-09-14 14:29:53', '84')
    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 's rihla', '2006-09-14 14:29:53', '84')' at line 4]
INSERT IGNORE INTO wp_global_posts (ID, blog_id, title, category, timestamp, post_id) VALUES ('', 19, '\'Ethical Sayings of the Prophet Muhammad\'', 'saliha's rihla', '2006-09-14 14:29:53', '84')

    Warning: Cannot modify header information - headers already sent by (output started at /home/..../public_html/wp-includes/wp-db.php:111) in /home/..../public_html/wp-content/mu-plugins/tw-autosave.php on line 119

    Warning: Cannot modify header information - headers already sent by (output started at /home/..../public_html/wp-includes/wp-db.php:111) in /home/...../public_html/wp-content/mu-plugins/tw-autosave.php on line 119

    Warning: Cannot modify header information - headers already sent by (output started at /home/..../public_html/wp-includes/wp-db.php:111) in /home/..../public_html/wp-includes/pluggable.php on line 281

    Happened on only *one* blog where I was trying to edit and save each post (so they would be added into the global categories database).

    Oddly enough it happened only sparingly depending on the post I was working on and not on every post I edited and saved.

  10. deltakid
    Member
    Posted 17 years ago #

    Hey suleiman such a search function would be easy to implement i guess. I will have a look into that as soon as I finished all core features.

    The problem seems to be the use of ' in the title I tried to replicate the problem but it didnt give me any error. Does your posts appear on the site?

  11. suleiman
    Member
    Posted 17 years ago #

    The post appears on the site deltakid, but only because it already existed there.

    What I did after I installed this plugin was to go through my existing blogs (since this site is just launching) and edit and then save each blog entry. In most instances this was enough to put it into the global category table we made, but on one particular blog I was having the above mentioned issues.

    What I'm worried about is someone trying to create a new post entry with a ' in the title and then coming up with this error after having written their entire post! Obviously a situation I want to try and avoid as much as possible.

    I'm still stuck on why this was happening on only one blog but not any others. I'll try writing a post with a ' in the title on my own blog and see if i can't reproduce the problem

    EDIT: Uh ohh.....I spoke too soon! Looks like I've done something here to muck up the updating process, as any posts made to any categories in any blogs aren't getting updated in the tags page any longer!

  12. boetter
    Member
    Posted 17 years ago #

    But is there no way of indexing/syncing old posts? I have approx. 15.000 posts, would take a while to re-publish all of them ;-)

  13. suleiman
    Member
    Posted 17 years ago #

    After playing around with the database, including dropping the table entirely and starting again from scratch, I've realized that I am unable on some blogs to have the entries update the tags page.

    If there are old entries on the blog from before the plugin installation, then those can be put onto the tags page by editing the posts and then saving them without makinga ny changes, but new posts simply aren't getting written at all on some blogs. (I tested with 3 of them).

  14. andrea_r
    Moderator
    Posted 17 years ago #

    I have a question, from th redundancy department. :)

    Why create a new table wp_global_posts when there's already a wp_global_categories? Every time a user adds a category, it gets stuck there as well, so.... why not use that?

  15. suleiman
    Member
    Posted 17 years ago #

    I'm guessing because deltakid has his own variables that he wants to store and get in the wp_global_posts table? Not really sure andrea.

    FYI deltakid, the problem was actually not the ' in the title but in the category name. One of my bloggers was posting to the category "Qur'an" and the ' in there caused an error. Deselecting categories with apostrophes allowed me to publish the post.

    But I am still having the error where no new posts from any blogs are appearing in the table unfortunately

  16. suleiman
    Member
    Posted 17 years ago #

    And...oddly enough the problem seems to be gone for now. I just deleted some white space in the post.php file and so far so good.

  17. deltakid
    Member
    Posted 17 years ago #

    Suleiman, thanks for your donation! Glad it works now I tested the same scenario you had a couple of times and had no problems so far. The edit & save way is the best right now to import old posts.

    But I'm going to write an update script today that you can run and all old posts from all blogs are put in the global posts table.

    Andrea_r I saw the global categories table but wanted to have a table with some more data about all posts.

  18. suleiman
    Member
    Posted 17 years ago #

    deltakid, I don't really understand because sometimes this works and sometimes it doesn't!

    For example, I just made a blog entry on my personal blog site, and it showed up there and the category I posted to did not contain an apostrophe.

    I purposefully created a new category because I wanted to see if the tag cloud would update itself. Which it did with my new category "Mac."

    But once I click on it there's nothing there. Both the RSS feeds and my personal blog list the new post. Any ideas why this might be happenning?

    FYI the link to my personal blog is http://suleiman.hadithuna.com
    The link to the tag cloud is http://www.hadithuna.com/tags/

  19. suleiman
    Member
    Posted 17 years ago #

    OKAY! Although I haven't come any closer to explaining any of this, I have figured out the fix to my problems about new posts not appearing: nothing.

    It just takes time. I made a post 5 hours ago to my blog, and checked back over an hour long period refreshing the page numerous times but got no results. Then all of a sudden it just appeared.

    The next time I make an entry I'm going to time it to see how long it takes, then I'll report back with more results. Thanks again deltakid.

  20. boetter
    Member
    Posted 17 years ago #

    suleiman: Couldn't that be plain caching? I wouldn't want the tag listings to refresh all the time either, my server would die.

  21. suleiman
    Member
    Posted 17 years ago #

    how long should it take boetter? What i don't understand is why updating a post saves it right away but making a new post doesn't have the same effect.

    i also searched my wp_global_posts table and found new entries were showing up right away when new posts were made, but they just didn't show up in the tag cloud till later.

    this isn't a deal breaker obviously, the functionality is still excellent. I'm just trying to figure out how long it takes "normally."

  22. deltakid
    Member
    Posted 17 years ago #

    I add pagination right now that people can browse older posts. The update script that adds all older posts to the global posts table is more or less done I think I finish it tomorrow.
    Got to get the permalinks working somehow... :( with pagination it has even more $_GET variables. Any advice from a mod_rewrite pro would be great.

    How to rewrite this here to look nice and neat?

    http://domain.com/?c=Uncategorized&page=2

    to something like this

    http://domain.com/Uncategorized/2/

    Please see also this thread here
    http://mu.wordpress.org/forums/topic.php?id=2379&replies=2

  23. deltakid
    Member
    Posted 17 years ago #

    I made an import script but it just works for the main / home blog. If anyone is interested you can find it here
    http://www.uhdinger.com/wpmu/update.zip

    Details how to use it are in the file itself. Delete it after use from your theme folder.

    I will continue working on this fix / plugin as soon as I have some more time. Right now I have too much other work to spend time on it.

  24. boetter
    Member
    Posted 17 years ago #

    It's great deltakid. Let us know when you have more time again, this plugin really could make the difference for WPMU adoption :-)

  25. suleiman
    Member
    Posted 17 years ago #

    definitely could, I can't wait to add everyone's posts to the master wp_global_posts table.

  26. a-bishop
    Member
    Posted 17 years ago #

    suleiman. did you create a separate page /tags/ and just pasted sample code to it? When I click on the tag on my page (rubhub.ru), it leads to wrong place instead of posts listing :-(

  27. a-bishop
    Member
    Posted 17 years ago #

  28. suleiman
    Member
    Posted 17 years ago #

    lol...a-bishop you just linked to this thread from this thread. A little redundant don't you think ;)

  29. a-bishop
    Member
    Posted 17 years ago #

    suleiman, actually I wanted to post it to another thread, that I've found Tag Cloud solution here, but my question about broken link is still unanswered :-(

  30. jahbini
    Member
    Posted 17 years ago #

    I'm attempting to bring up 'romancecapitol.com' as a romance and relationship site. I want the user's blog pages to have a sidebar that points to all post in all categories: a site wide cloud.
    What happens is this: The cloud consissts of all site wide categories, but the anchors themselves point to blog specific posts, rather than site-wide posts.
    It seems that two functions are needed: one that generates a site-wide cloud with site-wide anchors, and another function that creates a blog-specific cloud with blog-specific anchors.
    Another solution would be along the lines of: "I'm totally ignorant of the 'real' way to set up the permalinks, etc. and need to get with TFM (all 10,000 of them)"

1 2 3

About this Topic

  • Started 17 years ago by deltakid
  • Latest reply from mrjcleaver