Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
02/02/2011 08:52:58 AM (13 years ago)
Author:
johnjamesjacoby
Message:

First pass at introducing forums directory, single forum, and single topic views. This is mostly copy/paste from groups component with some rough logic in place to display the proper screens. More to do here.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-forums/bp-forums-template.php

    r4010 r4012  
    449449
    450450        $defaults = array(
    451             'type' => 'thumb',
    452             'width' => false,
     451            'type'   => 'thumb',
     452            'width'  => false,
    453453            'height' => false,
    454             'alt' => __( 'Profile picture of %s', 'buddypress' )
     454            'alt'    => __( 'Profile picture of %s', 'buddypress' )
    455455        );
    456456
     
    565565            $permalink = trailingslashit( bp_get_root_domain() . '/' . bp_get_forums_root_slug() . '/' . bp_current_item() );
    566566        else
    567             $permalink = trailingslashit( bp_get_root_domain() . '/' . bp_get_forums_root_slug() . '/' . $bp->current_action );
     567            $permalink = trailingslashit( bp_get_root_domain() . '/' . bp_get_forums_root_slug() );
    568568
    569569        return apply_filters( 'bp_get_the_topic_permalink', trailingslashit( $permalink . 'topic/' . $forum_template->topic->topic_slug ) );
     
    901901    if ( empty( $topic_id ) && bp_is_current_component( 'groups') && bp_is_current_action( 'forum' ) && 'topic' == $bp->action_variables[0] )
    902902        $topic_id = bp_forums_get_topic_id_from_slug( $bp->action_variables[1] );
     903    elseif ( empty( $topic_id ) && bp_is_current_component( 'forums') && bp_is_current_action( 'topic' ) && !empty( $bp->action_variables[0] ) )
     904        $topic_id = bp_forums_get_topic_id_from_slug( $bp->action_variables[0] );
    903905
    904906    if ( is_numeric( $topic_id ) ) {
     
    11071109}
    11081110
    1109 function bp_forum_permalink() {
    1110     echo bp_get_forum_permalink();
    1111 }
    1112     function bp_get_forum_permalink() {
    1113         global $bp;
    1114 
    1115         if ( $bp->is_single_item )
    1116             $permalink = trailingslashit( bp_get_root_domain() . '/' . $bp->current_component . '/' . bp_current_item() );
     1111function bp_forum_permalink( $forum_id = 0 ) {
     1112    echo bp_get_forum_permalink( $forum_id );
     1113}
     1114    function bp_get_forum_permalink( $forum_id = 0 ) {
     1115        global $bp;
     1116
     1117        if ( bp_is_groups_component() ) {
     1118            $permalink = trailingslashit( bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/' . bp_current_item() . 'forum' );
     1119        } else {
     1120            if ( empty( $forum_id ) ) {
     1121                global $topic_template;
     1122                if ( isset( $topic_template->forum_id ) )
     1123                    $forum_id = $topic_template->forum_id;
     1124            }
     1125
     1126            if ( $forum = bp_forums_get_forum( $forum_id ) )
     1127                $permalink = trailingslashit( bp_get_root_domain() . '/' . bp_get_forums_root_slug() . '/forum/' . $forum->forum_slug );
     1128            else
     1129                return false;
     1130        }
     1131
     1132        return apply_filters( 'bp_get_forum_permalink', trailingslashit( $permalink ) );
     1133    }
     1134
     1135function bp_forum_name( $forum_id = 0 ) {
     1136    echo bp_get_forum_name( $forum_id );
     1137}
     1138    function bp_get_forum_name( $forum_id = 0 ) {
     1139        global $bp;
     1140
     1141        if ( empty( $forum_id ) ) {
     1142            global $topic_template;
     1143            if ( isset( $topic_template->forum_id ) )
     1144                $forum_id = $topic_template->forum_id;
     1145        }
     1146
     1147        if ( $forum = bp_forums_get_forum( $forum_id ) )
     1148            return apply_filters( 'bp_get_forum_name', $forum->forum_name, $forum->forum_id );
    11171149        else
    1118             $permalink = trailingslashit( bp_get_root_domain() . $bp->current_component . '/' . $bp->current_action );
    1119 
    1120         return apply_filters( 'bp_get_forum_permalink', trailingslashit( $permalink . 'forum' ) );
     1150            return false;
    11211151    }
    11221152
Note: See TracChangeset for help on using the changeset viewer.