The MU forums have moved to WordPress.org

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

  1. Melodiefabrieknl
    Member
    Posted 19 years ago #

    there are really cool things about this plugin, but I think it will not work when you don't tweak categories.php as well. what if someone renames a category or deletes it for example? you want to keep track of that too I presume.

  2. zeug
    Member
    Posted 19 years ago #

    I guess when a post is saved in a new category and that entry is added, you'd need to check wp_global_posts for other categories belonging to that post then delete those that have been orphaned. Wonder how much extra cpu load that would be on a busy Mu with thousands of entries. Maybe a scheduled maintenance script could do it.

    Just installed it on a 1.0 subdomain Mu and was easy enough and is running smoothly so far. Can the post.php mods be run from the plugin itself on save using something like add_action('publish_post', '');

    It's a great start though and an awesome community tool as it really opens up the Mu blogs to browsing. Cheers.

  3. Melodiefabrieknl
    Member
    Posted 19 years ago #

    Yes, that would probably be the best way to do it. A few actions should be needed, so also the categories itself are being taken can off.

    I don't have the time to look into it too much right now. Hopefully someone else will. Cool things can be build on this for sure.

    Main thing must be: leaving the post.php un-edited and only use add_action or filters.

  4. jahbini
    Member
    Posted 19 years ago #

    I'm still haveing no success with the sidebar.php and setting a user's blog page to have a site wide cloud. Is this possible and what needs to be put into the sidebar.php?

    Thanks for your assistance.

  5. suleiman
    Member
    Posted 19 years ago #

    jahbini, the best way to do what you're looking for would be to code the functionality you want into a widget and then let your users drop it in to their blogs.

    Widgets are really the way to go on a multiple blogger site like you're building.

  6. Melodiefabrieknl
    Member
    Posted 19 years ago #

    there are a couple of things which also needs to be taken care off:
    - when a user changes the category name or deletes the category
    - when the whole blog is deleted (it now will show error messages because table is not found)

    add_action would be great I guess but I need to learn into it...

  7. suleiman
    Member
    Posted 19 years ago #

    I think another key issue is fixing this so it only puts data into the global_posts table if the blog is a public blog.

    Right now even blogs marked as private have their entries posted into table.

  8. Melodiefabrieknl
    Member
    Posted 19 years ago #

    would it be possible to use add_actions for this? I am no expert in this. I do believe that using this system should be fully compatible with all other WPMU settings, it should simply integrate. still can't believe why WPMU doesn't offer any aggregated features except for keep the category-id's of all blogs the same (WU-plugins global-categories.php).

    it is an excellent start, this plugin and I have fun adding and changing it a bit, but it's still not perfect... like all things :)

  9. flufftronix
    Member
    Posted 19 years ago #

    This is so great; I have two community blog projects that have been pretty much on hold waiting for something like this to get developed. I'll be implementing this stuff very soon, for sure. Thanks so much!

  10. conpeo
    Member
    Posted 19 years ago #

    Happy Newyear to all!

    I test to create new page for Import Script for old posts of the main blog, (http://www.uhdinger.com/wpmu/update.zip)

    when i view my new page it show error msg.

    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 ' 'testing', 'Blogroll', '2007-01-01 20:36:23', '5')' at line 4]
    INSERT IGNORE INTO wp_global_posts (ID, blog_id, title, category, timestamp, post_id) VALUES ('', , 'testing', 'Blogroll', '2007-01-01 20:36:23', '5')

    I go check my db not found blog_id in table wp_1_posts, but how come the update.php can import & insert the data to wp_global_posts? is it post_author = blogid ?

  11. flowers
    Member
    Posted 19 years ago #

    Great plugin, but i get the following error?
    Warning: array_values() [function.array-values]: The argument should be an array in wp-content/mu-plugins/global-cats.php on line 105 Warning: Wrong parameter count for max() in wp-content/mu-plugins/global-cats.php on line 105 Warning: array_values() [function.array-values]: The argument should be an array in wp-content/mu-plugins/global-cats.php on line 106 Warning: Wrong parameter count for min() in wp-content/mu-plugins/global-cats.php on line 106 Warning: Invalid argument supplied for foreach() in /wp-content/mu-plugins/global-cats.php on line 119 Warning: array_values() [function.array-values]: The argument should be an array in wp-content/mu-plugins/global-cats.php on line 105 Warning: Wrong parameter count for max() in wp-content/mu-plugins/global-cats.php on line 105 Warning: array_values() [function.array-values]: The argument should be an array in wp-content/mu-plugins/global-cats.php on line 106 Warning: Wrong parameter count for min() in wp-content/mu-plugins/global-cats.php on line 106 Warning: Invalid argument supplied for foreach() in wp-content/mu-plugins/global-cats.php on line 119

  12. mdvaldosta
    Member
    Posted 19 years ago #

    It'd be great to see this developed into a plugin, I don't have the ability but would be happy to support anyone who could.

  13. andrea_r
    Moderator
    Posted 19 years ago #

    Read the thread; it is a plugin.
    (is this guy spam???)

  14. lunabyte
    Member
    Posted 19 years ago #

    (maybe. it wouldn't surprise me.)

  15. mdvaldosta
    Member
    Posted 19 years ago #

    It's not a plugin, it's a hack (core edits). Eh. Unless I'm misreading: http://www.uhdinger.com/wpmu/global_categories.txt

    (yes, I'm spamming my username... lots of money in the "mdvaldosta" keyword. quite pathetic of me actually, but thanks for asking.)

  16. lunabyte
    Member
    Posted 19 years ago #

    (its the site, not the keyword. !nice try. <rolleyes>)

    It's part plugin, and a few edits. Unfortunately, that's what happens sometimes in order to make it work like you want.

  17. Manitu
    Member
    Posted 19 years ago #

    Hello everyone!

    Installed database changes.
    Made changes to post.php

    where should i place cats.php?
    And how can I see this plugin working?

    Thank you!

  18. amulheirn
    Member
    Posted 19 years ago #

    Hi Manitu,
    I don't think you put cats.php anywhere. It is an example of how to use the tags in your page template.

    I've been editing "wp-content/themes/home/home.php". This is because the main page of my site is using the "home" template.

    (Not sure if I am doing this right though - I get the tag cloud appearing, but when I click the tags it takes me to a general news item on the home page!)

    A.

  19. quenting
    Member
    Posted 19 years ago #

    > It's part plugin, and a few edits. Unfortunately, that's what happens sometimes in order to make it work like you want.

    yes, but in the case of this plugin it looks to me the code edits really aren't needed. delete post and publish post have action hooks and that's why they're here for, so this should really not have to edit those functions.

  20. mysorehead
    Member
    Posted 19 years ago #

    Hi,
    I've been working on a similar plugin which would double post a post to class blog (I'm a teacher) or a theme page eg. a topic page. The plugin is not finished but works as a proof of concept and works without edits.

    I don't think edits are needed and I only want to use pure plugins, I don't want to hack WP. Here is my code for the function in question, so far (in case it helps anyone) When this plugin is finished (admin pages...) I'll post it in full.

    function rgo_republish($post_ID) {
    global $wpdb;
    global $table_prefix;
    //Hiding errors as I still need to check if categories already exist in the group blog rather than just forcing them in!
    $wpdb->hide_errors();
    //STILL TO DO: Add a link to the poster's blog at the bottom of the post??
    //STILL TO DO: Post even though the checkbox wasn't ticked for some group memberships
    $i = 0;
    $groups = $_REQUEST["post_rgo_groups"];
    while ( sizeof( $groups ) > $i ) {
    $group_table = $wpdb->get_var("SELECT table_prefix FROM wp_rgo_group_blogs WHERE id = ".$groups[$i].";");
    //Add the post to the group blog -
    $wpdb->query("INSERT INTO ".$group_table."posts SELECT 'NULL', post_author, post_date, post_date_gmt, post_content, post_title, post_category,post_excerpt, post_status, comment_status, ping_status, post_password, post_name, to_ping, pinged, post_modified, post_modified_gmt, post_content_filtered, post_parent, guid, menu_order, post_type, post_mime_type,comment_count FROM ".$table_prefix."posts WHERE ID = ".$post_ID.";");
    //Add the category tags to the group blog
    //STILL TO DO: Change / delete / add any tags? eg. I can it footy - they call it football
    $wpdb->query("INSERT INTO ".$group_table."post2cat SELECT 'NULL', '".$wpdb->insert_id."', category_id FROM ".$table_prefix."post2cat WHERE post_id = ".$post_ID.";");
    //Add categories to the group blog as they may not exist
    $wpdb->query("INSERT INTO ".$group_table."categories SELECT ".$table_prefix."categories.* FROM ".$table_prefix."categories, ".$table_prefix."post2cat WHERE ".$table_prefix."categories.cat_ID = ".$table_prefix."post2cat.category_id AND post_id = ".$post_ID." AND NOT EXISTS (SELECT * FROM ".$group_table."categories WHERE cat_ID = ".$table_prefix."post2cat.category_id);");
    $i = $i + 1;
    }
    return $post_ID;
    }
    add_action('publish_post', 'rgo_republish');

  21. suleiman
    Member
    Posted 19 years ago #

    just a quick question mysorehead. Using deltakid's hack, a persistent problem has been where users have had apostrophe's in their Category name, numerous errors shot up when they went to save their post after assigning it to the apostrophe category.

  22. mysorehead
    Member
    Posted 19 years ago #

    Suleiman,

    What is the problem, I haven't come across it yet? I haven't had a good look at the existing plugins - more fooling around so I could see how it works

    Sounds like an issue with the insert/update query and way it uses quotes, I guess addslashes/stripslashes could be used? Or plugins could be checked so that doble quotes are used where possible???

    The gloable ctaegories/class/theme blogs is something I want to get sorted so if it is a real problem I'm happy to help. We used separate wordpress blogs last year at my school (about 70 by the end of the year) but this year I am keen to use MU.

    School doesn't doesn't start for another week down here in Australia, that's why I'm not in a hurry :)

    Richard (mysorehead)

  23. bellyup
    Member
    Posted 19 years ago #

    Suleiman or anyone else who has global tag links working...

    Could you let me (and A-Bishop) know how you setup the tag linking you have on your tags page: http://hadithuna.com/tags

    When using subdomains and permalinks the only tags that work are the ones that are in the main blog's list of categories.

    For example, someone creates a blog:
    blog.domain.com
    and creates and posts to a 'stuff' category. On the main blog's page, the tag cloud generated is:

    stuff Uncategorized

    The link to 'Uncategorized' works and goes to:
    http://domain.com/blog/category/Uncategorized

    The link to 'stuff' (the user's post) doesn't and goes to:
    http://domain.com/blog/category/stuff
    returning a 'Ooops...Where did you get such a link ?' error.

    How does one go about making the tags page as found on:
    http://hadithuna.com/tags
    where the links from each tag work for all posts, not just those made on the main blog?

    can anyone enlighten me?

    James.

  24. drmike
    Member
    Posted 19 years ago #

    I did a method here and disgussed how to do a tag cloud.

    Hope this helps,
    -drmike

  25. bellyup
    Member
    Posted 19 years ago #

    Thanks drmike, I've invested enough time in this threads solution to want to get it working (it's really close, just not making the permalinks properly). Also I like the idea of not using the RSS feeds internally, just using the table lookups.

  26. suleiman
    Member
    Posted 19 years ago #

    bellyup, are you using subdomains or subfolders?

    My links to the different categories on the tags page look like this: hadithuna.com/tags/?c=Muslims, so I'm not really using the permalinks right now.

    I didn't modify anything from what delta kid posted, except for a minor modification to allow my categories to load on the mainsite if clicked on from any page (I have a site-wide tags widget that I installed--will post on here later).

  27. bellyup
    Member
    Posted 19 years ago #

    Suleiman. thanks for the reply. I am using permalinks and it doesn't seem to generate them properly as discussed above. I did get it working (hack of a hack) using the following (for those that are having similar troubles).

    Modified the primary blog's archive.php page, replacing it with this:

    <?php get_header();?>
    <div id="content">
    <div id="content-main">
    <?php gc_recent_posts(20, $_GET['c']); ?>
    </div><!-- end id:content-main -->
    <?php get_sidebar();?>
    <?php get_footer();?>

    Then any tag I want to retrieve all posts for i call using:
    http://domain.com/blog/category/uncategorized/?c=real_tag_here

    Where 'real_tag_here' is the tag name for which you have some posts.

    So it's not ideal but it works...

  28. suleiman
    Member
    Posted 19 years ago #

    why are you using archive.php? I just made a copy of my single.php file and went from there. Most good themes will include a blank page template for you to insert php code into, I would try and use one of them instead of hacking the archives.php file.

  29. suleiman
    Member
    Posted 19 years ago #

    to those of you that are using this hack/plugin/whatever we're calling it, are you getting any of the data on your tags page indexed by google? I just saw an error on my google webmaster page indicating my sitemap had errors, and that it couldn't follow the URL: http://hadithuna.com/tags/?c=Soapbox, despite that link working great in a browser.

    Any clues my peeps?

  30. mterrabuio
    Member
    Posted 19 years ago #

    Can anyone put the files of a working version of this hack for download?

About this Topic

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