Skip to:
Content
Pages
Categories
Search
Top
Bottom

bpContents 1.0 Alpha 1 – Member, Group and Blog Tagging for BuddyPress

  • @burtadsit

    Participant

    bpContents 1.0 alpha 1

    Requirements


    WordPress MU 2.7.1

    BuddyPress 1.0

    Demo at: http://ourcommoninterest.org/

    Description


    bpContents is a sitewide content aggregation and organization tool for BuddyPress.

    Features


    Member, Group and Blog tagging.

    Custom Member, Group and Blog directories. Standard WordPress tag cloud widgets and tag cloud template tags for Members, Groups and Blogs. Enhancements to the member theme by creating a new BP component.

    Member Tags:


    Each BuddyPress user can create profile tags that represent their interests. Visit My Account > Tags > Edit to create individual user tags. Enter a comma separated list of tags.

    Member profiles have been extended to include their individual tags with a user tag cloud visible in each user’s profile – My Account > Profile. A tag cloud is visible in the option’s bar that represents that particular user’s tags.

    The BP Member directory has been extended to include a site wide member tag cloud. Selecting a tag from the site wide cloud, displays all members with a similar tag in the directory. The directory functions as a normal member directory with letter selection and search active. The default BP directory was hijacked with one of Andy’s filters and the directory in /oci-contents/directories/members is displayed instead. The new tagging features in the directory were implemented by extending the default member template class and creating a new oci_has_site_members() template tag to fire up the extended template class.

    A widget for sitewide Member Tags is distributed with bpContents. Activate it in the normal sidebar widget fashion through the wp back end Appearance > Widgets > Member Tags. The wp widget directs tag clicks to the bp member directory.

    Group Tags:


    Each BP Group can create individual tags to allow easier discovery. Any Group admin or moderator can create group tags by going to the group home page Groups > My Group > Tags.

    The Group home has been extended with an individual group tag cloud visible in a similar place as the Member tags in the profile. Groups > My Group > Home.

    The Group directory has been enhanced the same way as the Member directory.

    A widget for sitewide Group Tags is distributed.

    Blog Tags:


    Each blog in a wpmu installation can be tagged through the blog’s Blog Tags widget. Visit Appearance > Widgets > Blog Tags.

    There is an additional option in the Blog Tags widget for tags. Enter a comma seperated list of tag names to tag each individual blog. You do not have to actively display each blog’s Blog Tag widget. However you must use the blog widget on each blog at least once to create the tags for that blog. You can then uninstal the widget if you prefer not to display it. You just have to get those tags in there once by using it once and saving the widget. If you are not actively displaying a blog’s tag widget you’ll have to activate it temporarily to change the blog tags.

    The BP Blog directory has been hijacked like the other directories. It displays a sitewide blog tag cloud and it functions as a normal directory also.

    Installation:


    1) unzip the bpcontents.zip file into /wp-contents/plugins/oci-contents

    2) Copy the template directory /wp-content/plugins/oci-contents/oci-contents to the member theme directory:

    /wp-content/bp-themes/bpmember/oci-content

    That directory should be at the same level as /bpmember/groups and /bpmember/profile etc..

    2) activate the plugin site wide

    Activating the plugin creates four new tables in the wpmu db.

    oci_tree

    oci_terms

    oci_items

    oci_tree_meta

    Have fun, be good. ~ Burt

    Download link available at the bottom of this:

    http://code.ourcommoninterest.org/2009/05/25/bpcontents-10-alpha-1-member-group-and-blog-tagging-for-buddypress/

    P.S. If you were running bpContents 0.1x Dev Sneak Peek previously, drop all the oci_ tables and then activate 1.0 Alpha 1.

Viewing 25 replies - 1 through 25 (of 25 total)
  • @talk2manoj

    Participant

    Hi Burt,

    This seems amazing! looking forward to use the same.

    Can we use this along with our custom developed component?

    Thanks

    @burtadsit

    Participant

    I’m not sure what you mean Manoj. It will work with other bp custom plugins yes. Is it going to be enhanced to allow you to use it in your own components. Yes also.

    @talk2manoj

    Participant

    Thanks for the quick answer. Yes, I want to use it in my own component.

    @talk2manoj

    Participant

    When I add tag in Group its says

    string 'http://domain.com/groups/admin-group-name/edit' (length=49)

    @rogercoathup

    Participant

    Hi Burt,

    this looks excellent for a new project we have starting.

    Is there any way of restricting the tags that can be applied? i.e. the administrator / developer defines the list of allowed tags, and the member has to chose tags from that list.

    Members on the new project will be businesses, and we want to be able to categorise them, i.e. as Accountants, Restaurant, Newsagent, Bank, etc. We have about 20 categories in total.

    Cheers,

    Roger

    @burtadsit

    Participant

    @manoj, never seen that. You running wpmu 2.7.1, bp 1.0 and bpc is installed properly?

    @burtadsit

    Participant

    @roger, this version works just like wp’s tag system. No restrictions. It is possible to do what you are talking about. It would take some custom programming to do so. I’m not going to document this for programmers yet. After things are stable with this project I will.

    However, it is intended as a tool for site admins and programmers to use. I’m trying to get the core stable in all environments first. This release is intended to do that. When it gets to beta I’ll document the core and the template tags. This purpose of this version is to get something useful out there. Knock a couple of features off Andy’s wish list for bp 1.x.

    This is an end user version at the moment.

    @rogercoathup

    Participant

    @burt, thanks for the quick response

    I’ll hopefully get it downloaded this week, and running on a site we already have out there… speed up the testing for you!

    Cheers,

    Roger

    @roymckenzie

    Participant

    Received this error when posting a new tag to a group as admin:

    <br />
    string(60) "http://modestobuzz.com/groups/modesto-area-disk-golfers/edit"<br />
    Warning: Cannot modify header information - headers already sent by (output started at /home/chedstone/webapps/modbuzz/wp-content/plugins/oci-contents/oci-contents.php:292) in /home/chedstone/webapps/modbuzz/wp-includes/pluggable.php on line 856<br />

    Blank page with the above text on it. The tag was still added though.

    Running BP 1.0 and WPMU 2.7.1

    @burtadsit

    Participant

    Everybody posting problems please state your bp version, wpmu version. Maybe a link to the site with the issue would help. This is successfully running on the demo site http://ourcommoninterest.org/ using WPMU 2.7.1, BP 1.0 and also under Windows.

    @apeatling

    Keymaster

    oci-contents.php line 292 there is var_dump() call that is causing the problems above.

    @burtadsit

    Participant

    Ha! Yep. Andy is right. Delete that line and things should work alot better. Oops. Fixing the download. Thanks Andy.

    3000+ lines of code and one var_dump() included for free.

    @burtadsit

    Participant

    Oh. Before anyone publicly complains, no, there isn’t any pagination included in alpha 1’s directories. I’m totally ignoring it on purpose. All the code is there ready to take advantage of it but I purposely didn’t implement it.

    bpc uses a mechanism called Modifed Pre-Order Tree Traversal (MPTT) that was specifically designed to track tree like structures in SQL tables. I need to find out if that part of the core is working properly. I had no intention of introducing another complexity down at the SQL level right now. As far as I can tell the MPTT implementation is stable.

    I swore I wasn’t gonna document this for programmers yet but I guess it wouldn’t hurt to talk about MPTT now.

    When you look at the properties for a node, in the class OCI_Node, you’ll notice two vars $this->lft and $this->rgt. These are MPTT specfic vars that represent the parent/child relationships of all nodes in the tree. . See these for info about MPTT:

    http://www.sitepoint.com/article/hierarchical-data-database/

    http://dev.mysql.com/tech-resources/articles/hierarchical-data.html

    http://www.dbmsmag.com/9604d06.html

    A simple node insert operation in the tree has a good chance of changing 50% of the lft/rgt values in the entire tree.

    Any sql operation that changes these values must:

    1) lock the table

    2) get the node and it’s valid lft/rgt values

    3) do the operation

    4) unlock the tree

    The only reliable property for a node in the tree is the $this->id which is the record id in the table.

    The boys and girls at wp are investigating MPTT right now for a future version of wp. I can’t wait around until they get to that so I’ve implemented this in bpc. It’s a natural for this kind of project and has many advantages.

    @johnjamesjacoby

    Keymaster

    Good job Burt!

    @burtadsit

    Participant

    I said I wasn’t going to document the code yet. I will tell you how it works though. :)

    bpc allows any type of content to be organized into a hierarchy. Think of it as a virtual file system implemented with SQL tables and relationships. Each path in the tree can have it’s own set of tags and content items.

    bpc 1.0a1 creates a tree consisting of member, group and blog tags.

    root

    — user

    — group

    — blog

    That’s the tree for bpc 1.0a1. All content, tags or items, are children of the tag ‘root’. Root is invisible to everyone and it’s the only thing allowed at it’s level. All other content is organized as children of ‘root’.

    Below root are the tags ‘user’, ‘group’ and ‘blog’. These tags are invisible to the end users also. When a bp member tags their profile they create other tags that are forced to be children of ‘user’.

    root

    — user

    —- cats

    —- dogs

    —- fish

    These tags form the member tag cloud. That cloud template tag looks in the path ‘root/user’ and displays everything it finds there. I’m just going to stop saying ‘root/user’ and use ‘/user’. The root is implied by the first slash. Just like a file system.

    What actually happens further is that an content item representing the user who created the tags ‘cats’, ‘dogs’ and ‘fish’ tags is put in each tag. We wind up with this:

    root

    — user

    —- cats


    item (burt)

    —- dogs


    item (burt)

    —- fish


    item (burt)

    These ‘items’ are content neutral representations of any type of content. In the case of items in /user, all items are derived from the bp user that created the tag. In the case of this tree some people want to be tagged differently and some the same:

    root

    — user

    —- cats


    item (burt)


    item (john)


    item (jeff)

    —- dogs


    item (burt)


    item (john)

    —- fish


    item (burt)

    —- giraffes


    item (jeff)

    —- bears


    item (john)

    When a user creates their own set of individual tags bpc inserts an item for them into an existing tag or creates a new one.

    So we’ve got a tag cloud now. In bpc the links in the tag cloud launch the content specific bp directory. A member tag cloud launches the member directory with a query param like /members?tags=cats

    The member directory has been modified by extending the normal template class that bp uses to pay attention to those $_GET vars if they exist in the url.

    The directory parses the $_GET query vars and determines what tag the user clicked on. In this case the tag was ‘cats’. The directory template class then gets all the items in the path /user/cats. These things it gets back from bpc are not the actual user records we need to display in the directory, they are instances of the class OCI_Item. That neutral representation of the original content.

    We get neutral representations of original content from classes that understand the original content types. They know where they came from and how to convert them to OCI_Items. Each content type that wants to store info in bpc has to have one of these conversion classes. In the case of bp members the class is called OCI_Item_User and it is a derived class of OCI_Item.

    It’s defined like: OCI_Item_User extends OCI_Item. You’ll see it in the oci-classes.php file. There’s three like that in there. One each for users, groups and blogs. The purpose of these classes is to convert source content into item format and when the time comes, take the item information and get() the original item back.

    This is the template class for the member directory:

    class OCI_BP_Core_Members_Template extends BP_Core_Members_template.

    When this class is fired up by the user clicking on a tag in the member tag cloud, the directory is launched. The template is run and in the constructor for OCI_BP_Core_Members_Template, it does a bunch of stuff and gets to the following chunk of code (lines 170-188 in oci-classes.php):

    } else if (isset($_GET[$bp->contents->slug])) {

    if (!$path)
    return;

    $tag = $path . '/' . $_GET[$bp->contents->slug];

    $container = new OCI_Container('path=' . $tag);
    $items = $container->get_items();
    foreach ($items as $item){
    $tmp->user_id = $item->item_id;
    $users['users'][] = $tmp;
    unset($tmp);
    }

    $users['total'] = count($users['users']);
    $this->members = $users;
    } else {

    If there are any query vars such as /members/?tags=cats then instantiate an OCI_Container for the path ‘/user/cats’ and get all the items in that tag.

    When the OCI_Item_User creates each member item in a tag it stores the user id in the var $this->item_id. The group version and the blog versions of that class store the group or blog ids in that spot when they create items.

    I took a look at the the bp template class and figured out that it needs an array of the format: array(‘users’ => $users, ‘total’ => $count) to operate properly so that’s what gets built for it in that chunk of code.

    Group and Blog templates use a similar thing. So we just pull out the user ids stored in each item and create an array that bp’s template class is happy with.

    All I had to do to modify the the directories was create a new bp_has_whatever() tempate tag and override the constructor for each template class that bp uses.

    Now we’ve got some modified php templates, classes and a replacement has_whatever() template tag function. It’s a good thing that Andy is filter and action happy because the only other thing to do was to create a filter that tells bp to use our new directories instead of the standard ones.

    // changes the default members dir to this one
    function oci_filter_template_directory_members(){
    return ('oci-contents/directories/members/index');
    }
    add_filter('bp_core_template_directory_members', oci_filter_template_directory_members');

    That function lives in oci-templatetags.php. There’s one for each of the directory types being hijacked.

    @burtadsit

    Participant

    I’m gonna write a post that talks about simulating wp’s category system next with bpc. The layout for the tree would look something like this:

    root

    — group

    —- ‘authorized user’ created category 1


    end user tag 1


    end user tag 2

    —- ‘authorized user’ created category 2


    end user tag 1


    end user tag 2

    So that groups are first labeled with a category, perhaps at group creation time and all group tags go into a default category for the group. Depending on the type of group.

    It would help in the situation where, like now, you have a zillion group tags of different types mixed in together. Sites could ‘categorize’ groups and then allow tagging of the groups by group admins within the group category.

    group

    — dogs

    —- dog breed tags

    — cats

    —- cat breed tags

    — fish

    —- fish breed tags

    Do fish have breeds? :)

    The advantage to the end user is they could pick a category first and the tag cloud would reflect only that categories tags.

    @burtadsit

    Participant

    For jeffsayre:

    // Check for bp being loaded, if not try and load it
    // Insures that bp is loaded before this plugin
    if (!function_exists('bp_core_setup_globals')){
    if ( file_exists( WP_PLUGIN_DIR . '/buddypress/bp-loader.php' ) ){
    require_once( WP_PLUGIN_DIR . '/buddypress/bp-loader.php' );
    }
    else{
    echo "BuddyPress is not installed!";
    return;
    }
    }

    This seems to work Jeff. Just doing bp-core.php doesn’t. The loader is the one we need.

    @jeffsayre

    Participant

    Burt-

    Very nice indeed! I’ll put this in the unofficial Skeleton Component v1.3.

    @skollie

    Participant

    Is the category system only going to be part of a later plugin release or can one already tweak the code now to enable it?

    @jeffsayre

    Participant

    Skollie-

    Burt is hard at work on the alpha2 release of bpc. Once he has some time, I’m sure he’ll get around to writing that post he promised.

    @roymckenzie

    Participant

    Great job @Burt!

    @burtadsit

    Participant

    Skollie, the core for implementing categories is already there. Laying about the place. It’s really just deciding that content and containers in the path /category are sitewide categories and building the permissions and UI around the concept.

    I’m ‘tweaking’ the alpha 2 version to have the perspective of categories that are tightly controlled by the site/group/blog admins but selectable by the user. Tags will remain the free form folksonomy approach to categorization of content.

    The control over who gets to create and change what in bpc is pretty rigid right now. It’s not very flexible because we need a sitewide access control mechanism. That’s in the works for buddypress though. There’s a couple of devs laying about doing absolutely nothing so we poked ’em with sticks and they are working on it. :)

    @skollie

    Participant

    Would it be possibile for group admins to create own categories for their groups, then add in tags as needed? Or is the site admin gonna have to constantly decide which group fits in where?

    @burtadsit

    Participant

    Well, with alpha 2. Site admins will create member, group and blog categories. Then members can choose one or more cats they fit. Same for group and blog admins. It’s the site admin’s site. They get to determine the categories.

    Of course cats can be added or deleted as needed by the site admin. The site admin sets everything up and people pick and choose appropriately where they fit in. The member, group and blog tags extend and enhance this by allowing free form additions to the categorization process. Then either or both the cats/tags could be used to discover people, groups or blogs.

    Since the categories aren’t as fluid as the tags, you could allow users to categorize themselves during signup. People can use categories to get a broad idea of the site content and then narrow it down with tags. Things like that.

    @idotter

    Participant

    Will this plugin be maintained and/or pushed forward in the future ?

Viewing 25 replies - 1 through 25 (of 25 total)
  • The topic ‘bpContents 1.0 Alpha 1 – Member, Group and Blog Tagging for BuddyPress’ is closed to new replies.
Skip to toolbar