SOME HELP PLEASE!!!
I’m very confused.
If I look into the function, I can’t find the parameter ” most-forum-topics “.
There is just active ( default ) | random | newest | popular.
But its working in the directory/forums view.
function bp_has_site_groups( $args = '' ) {
global $site_groups_template;
$defaults = array(
'type' => 'active',
'per_page' => 10,
'max' => false
);
$r = wp_parse_args( $args, $defaults );
extract( $r, EXTR_SKIP );
// type: active ( default ) | random | newest | popular
if ( $max ) {
if ( $per_page > $max )
$per_page = $max;
}
$site_groups_template = new BP_Groups_Site_Groups_Template( $type, $per_page, $max );
return apply_filters( 'bp_has_site_groups', $site_groups_template->has_groups(), &$site_groups_template );
}
This function helps provide the ‘Latest Forum Topics’ list of topics which is default; part of the parent theme on the forum index page.
For your help:
Here is the case breakout of the types
switch ( $type ) {
case 'active': default:
$this->groups = groups_get_active( $this->pag_num, $this->pag_page );
break;
case 'alphabetical': default:
$this->groups = groups_get_alphabetically( $this->pag_num, $this->pag_page );
break;
case 'random':
$this->groups = groups_get_random_groups( $this->pag_num, $this->pag_page );
break;
case 'newest':
$this->groups = groups_get_newest( $this->pag_num, $this->pag_page );
break;
case 'popular':
$this->groups = groups_get_popular( $this->pag_num, $this->pag_page );
break;
case 'most-forum-topics':
$this->groups = groups_get_by_most_forum_topics( $this->pag_num, $this->pag_page );
break;
case 'most-forum-posts':
$this->groups = groups_get_by_most_forum_posts( $this->pag_num, $this->pag_page );
break;
}
As you can see, if specifying ‘most-forum-topics’ it runs:
groups_get_by_most_forum_topics()
From there it does a straight up dynamic select to the database to get the forum data.
Hi JasonG, thanks for your help.
You wrote: Here is the case breakout of the types.
Where did you find this? Do you have a function name for me?
I still have problems to bring it to work. Hire is the original function from the parent theme on the forum index page. It calls bp_has_site_groups( ‘type=most-forum-topics&max=6’ )
If I look into this function I cant find the switch case from your post.
How to use groups_get_by_most_forum_topics()??
Do you have an example?
I’m looking forwart to your replay!
<?php if ( bp_has_site_groups( 'type=most-forum-topics&max=6' ) ) : ?>
<div id="popular-group-forum-listing">
<h3><?php _e( 'Popular Group Forums', 'buddypress' ) ?></h3>
<?php do_action( 'bp_before_directory_popular_group_forums' ) ?>
<?php while ( bp_site_groups() ) : bp_the_site_group(); ?>
<div class="group-forum">
<div class="item-avatar">
<a href="<?php bp_the_site_group_link() ?>/forum/"><?php bp_the_site_group_avatar_thumb() ?></a>
</div>
<div class="item">
<div class="item-title"><a href="<?php bp_the_site_group_link() ?>/forum/"><?php bp_the_site_group_name() ?></a> (<?php bp_the_site_group_forum_topic_count( 'showtext=true' ) ?>, <?php bp_the_site_group_forum_post_count( 'showtext=true' ) ?>)</div>
<div class="item-meta desc"><?php bp_the_site_group_description_excerpt() ?></div>
<?php do_action( 'bp_directory_popular_group_forums_item' ) ?>
</div>
</div>
<?php endwhile; ?>
<?php do_action( 'bp_after_directory_popular_group_forums' ) ?>
</div>
<?php endif; ?>
Try these pointers
– Try and use the intended function in the same manner as the stock theme. To make sure everything works.
– Understand that forums and topics must exist to be filtered, much like any of the status filters for widgets such as the latest user/group activities.
– Try using ‘groups_get_by_most_forum_topics()’ function directly in your custom function.
– Start debugging, turn debugging flags on for your environment, start to modify the source and see whats going on.
Thanks a lo for your help, its working now.
I did it like this:
first I need to change the body class:
<?php
function new_body(){
return 'directory forums';
}
add_filter( 'body_class', 'new_body', 0, 2 );
?>
and then I need to modify the index.php from the forum directory.
with the modified version I can call the forum directory everywhere.
<?php include (STYLESHEETPATH . '/directories/forums/index.php'); ?>
<?php
global $site_groups_template;
$defaults = array(
'type' => 'type=most-forum-topics&max=6',
'per_page' => 10,
'max' => 6
);
$r = wp_parse_args( $args, $defaults );
extract( $r, EXTR_SKIP );
// type: active ( default ) | random | newest | popular
if ( $max ) {
if ( $per_page > $max )
$per_page = $max;
}
$site_groups_template = new BP_Groups_Site_Groups_Template( $type, $per_page, $max );
?>
<?php if ( $site_groups_template->has_groups() ) : ?>
….