Don’t know if this is any use to anyone and no doubt there are far better ways of doing it but just in case it is of use….
I’ve created (hacked really) a plugin made up of 3 files, one of which is useless for now but at a future point I’d like to play around with it.
bp-group-catdisp.php
`<?php
/*
Plugin Name: Display Categories
Plugin URI:
Description: Displays a blog category in groups
Author: Mas
Version: 0.1
License: GNU General Public License 2.0 (GPL) http://www.gnu.org/licenses/gpl.html
Site Wide Only: true
*/
if ( !defined( ‘BP_GROUP_CATDISP’ ) )
define ( ‘BP_GROUP_CATDISP’, ‘programme’ );
function bp_group_catdisp_init() {
bp_group_catdisp_wrapper();
}
if ( defined( ‘BP_VERSION’ ) )
bp_group_catdisp_wrapper();
else
add_action( ‘bp_init’, ‘bp_group_catdisp_init’ );
//above links to admin screen in backend
require(dirname(__FILE__) . “/bp-group-catdisp-admin.php”);
// group options
function bp_group_catdisp_wrapper() {
class bp_group_catdisp extends BP_Group_Extension {
var $visibility = ‘private’;
var $enable_create_step = false;
var $enable_edit_item = false;
var $has_caps = false;
function bp_group_catdisp () {
global $groups_template;
// group title
$this->name = __( ‘Programme’, ‘programe’ );
$this->slug = BP_GROUP_CATDISP;
$this->nav_item_position = 12;
$this->create_step_position = 12;
// group ID for displaying category within
global $bp;
$group_array = array( 17,11 );
if ( in_array( $bp->groups->current_group->id, $group_array) )
//group ID to display in array. Note can reverse this code ie. set it not to display in listed groups by placing !in_array( $bp etc.
{
$this->enable_nav_item = true;
} else {
$this->enable_nav_item = false;
}
}
function display () {
global $bp, $groups_template;
include(“bp-group-catdisp-edit.php”);
//bit above links to file that prints to tab
}
}
bp_register_group_extension( ‘bp_group_catdisp’ );
}
?>
`
bp-group-catdisp-edit.php
`
Information and modules related to the Y-Care Programme 2010/11
<a href="” rel=”bookmark” title=”Permanent Link to “>
Sorry, no posts matched your criteria.
`
bp-group-catdisp-admin.php
`<?php
function group_catdisp_add_admin_menu() {
add_submenu_page( ‘bp-general-settings’, __( ‘Group Categories’, ‘bp_group_catdisp’ ), __( ‘Disp Cats’, ‘bp_group_catdisp’ ), ‘manage_options’, __FILE__, ‘group_catdisp_plugin_options’ );
}
add_action(‘admin_menu’, ‘group_catdisp_add_admin_menu’, 15);
function group_catdisp_plugin_options() {
if (!current_user_can(‘manage_options’)) {
wp_die( __(‘You do not have sufficient permissions to access this page.’) );
}
$updated = false;
//above this is php for creating admin page and below is printed onto admin page
?>
<?php
if ( !$options = get_option( ‘bp_gm_settings’ ) )
$per_page = 10;
else
$per_page = $options;
$args = array( ‘type’ => ‘alphabetical’, ‘per_page’ => $per_page );
if ( $_GET == ‘name’ )
$args = ‘alphabetical’;
else if ( $_GET == ‘group_id’ )
$args = ‘newest’;
else if ( $_GET == ‘popular’ )
$args = ‘popular’;
if ( $_GET )
$args = $_GET;
else
$args = 1;
if( bp_has_groups( $args ) ) :
global $groups_template;
?>
|
|
|
Category |
<?php
if ( !$group )
$group =& $groups_template->group;
?>
|
|
|
|
Categories
|
You don’t have any groups to manage.
<?php
}
?>
`
The first two hard code a group by ID and display a selected wordpress category within that group. The last file is the useless one. I’d started hacking from one of @boonebgorges plugins with the idea of creating an admin screen from which groups could be linked to blog categories.
I’ve run out of time for now to play with that further and so for now am just going to duplicate the first two files for another couple of groups which will work for my purposes.