Pete (@uniquepete)

Forum Replies Created

Viewing 10 replies - 1 through 10 (of 10 total)

  • Pete
    Participant

    @uniquepete

    Brilliant. Yep, the Moderation options include what I was after.

    Thanks!


    Pete
    Participant

    @uniquepete

    Working with your original solution, your subsequent advice, playing with code segments from relevant template files, and a bit of dumb luck, the following augmented version of your function seems to work:

    
    function rew_breadcrumb_search ($crumbs) {
    	//create a new array
    	$new_crumbs = array() ;
    	$first_pass = true;
    	$augment_breadcrumbs = true;
    	//find the forum from the first item in results
    	if ( bbp_has_search_results()) {
    		while ( bbp_search_results() ) : bbp_the_search_result(); 
    		$type = get_post_type() ;
    		if ($type == 'topic' ) $forum_id = bbp_get_topic_forum_id() ;
    		if ($type == 'reply' ) $forum_id = bbp_get_reply_forum_id() ;
    		if ( $first_pass ) {
    			$first_pass = false;
    			$last_forum_id = $forum_id;
    		} elseif ( $forum_id !== $last_forum_id ) {
    			$augment_breadcrumbs = false;
    		}
    //		if (!empty ($forum_id)) break ;
    		endwhile ;
    	}
    	//cycle through the crumbs until we find search
    	foreach ($crumbs as $crumb=>$data) {
    		//shouldn't really need to do this inside the loop, but the alternatives crashed	
    		if ( $augment_breadcrumbs ) {
    			if (strpos($data, 'search') !== false) {
    				//If the forum ID exits, add the breadcrumb
    				if ( $forum_id && is_numeric( $forum_id ) ){
    					//Use the Forum ID we found in the search result
    					$new_crumbs[] = '<a href="' . esc_url( bbp_get_forum_permalink( $forum_id ) ) . '" class="bbp-breadcrumb-forum">' . bbp_get_forum_title( $forum_id ) . '</a>';
    				} else {
    					//The search result was empty, so we need to get the Forum ID from the search request(?)
    					$forum_id = sanitize_title_for_query( $_GET['bbp_search_forum_id'] );
    					if ( $forum_id && is_numeric( $forum_id ) ){
    						$new_crumbs[] = '<a href="' . esc_url( bbp_get_forum_permalink( $forum_id ) ) . '" class="bbp-breadcrumb-forum">' . bbp_get_forum_title( $forum_id) . '</a>';
    					}
    				}
    			}
    		}
    			$new_crumbs[] = $data ;
    		}
    	return $new_crumbs ;
    }
    add_filter ('bbp_breadcrumbs' , 'rew_breadcrumb_search' ) ;
    

    It does seem a little complicated, but all my attempts to cut out bits that don’t immediately look necessary breaks things, so I have what I have—but it does produce the desired outcome.

    Thanks for your help. It was very much appreciated.


    Pete
    Participant

    @uniquepete

    That worked so, just for the record, the code to be inserted in the loop-search-reply.php template file is:

    
    <div class="bbp-topic-title-meta">
    
    	<?php if ( function_exists( 'bbp_is_forum_group_forum' ) && bbp_is_forum_group_forum( bbp_get_topic_forum_id() ) ) : ?>
    
    		<?php esc_html_e( 'in group forum ', 'bbpress' ); ?>
    
    	<?php else : ?>
    
    		<?php esc_html_e( 'in forum ', 'bbpress' ); ?>
    
    	<?php endif; ?>
    
    	<a href="<?php bbp_forum_permalink( bbp_get_topic_forum_id() ); ?>"><?php bbp_topic_forum_title( bbp_get_topic_forum_id() ); ?></a>
    
    </div><!-- .bbp-topic-title-meta -->
    
    <?php do_action( 'bbp_theme_after_topic_title' ); ?>
    

    Pete
    Participant

    @uniquepete

    OK, it did it again. There’s something else I don’t understand… how text that is inserted in ‘code’ tags are interpreted. Let’s try this one more time… The relevant function call to be inserted in the above code segment is:

    
    <a href="<?php bbp_forum_permalink( bbp_get_topic_forum_id() ); ?>"><?php bbp_topic_forum_title( bbp_get_topic_forum_id() ); ?></a>
    

    Pete
    Participant

    @uniquepete

    OK, so I totally misunderstood what was going on there… The ‘bbpress’ text has nothing to do with the display of the forum name.

    The result I was after is acheived quite simply by using the function bbp_topic_forum_title in place of bop_forum_title in the above code segment (which still needs to be added to the loop-search-reply.php template—and that modified template file placed in the relevant <theme>/bbpress folder—as noted above):

    "><?php bbp_topic_forum_title( bbp_get_topic_forum_id() ); ?>

    Now, as I retype that code segment, I notice that something has gone wrong with the code segment I pasted into the original post. I’m not sure if that was me or not, but the line to be replaced with the above, should have been as follows:

    "><?php bbp_forum_title( bbp_get_topic_forum_id() ); ?>

    I hope that makes sense to anyone who’s interested.


    Pete
    Participant

    @uniquepete

    Ahh! To the reader left as an exercise it is!

    Thanks, I’ll see how I go.


    Pete
    Participant

    @uniquepete

    Thanks Robin. That’s given me something to work with.

    As it stands, this will include the current forum in the breadcrumb if the search is executed from a specific forum and the result set is not empty. That is certainly one of the cases addressed.

    But if the search is executed from the main index page, and the result set is not empty, instead of the breadcrumb trail including just Forums > Search > etc., it will include the name of the the first forum that produced a search hit (and obviously not all, where there may be several hits in different forums), which is not really the intent.

    If the search set is empty, however, the name of the forum from which the search was conducted is still missing and I’m not sure I can work out how to get around that, because your code is using one of the search hits to work out what forum to add to the breadcrumb. If the search set is empty, how then can I work out where I’ve come from? I think I’m going to have to know this to even fix the first problem above.

    Is there a concept of something like a global variable here? Can we set the $forum_id variable any time we navigate to a particular forum and just call on that from where ever we are if needed?

    I think it will be the case of the empty search where this will come in most handy, because the reader can quickly flick back to the forum in question and search again, rather than having to go back to the main index page and navigate back to the forum they were working with if they, for example, have just mistyped a search string.

    Thanks again. I had no idea where to even begin…


    Pete
    Participant

    @uniquepete

    OK, thanks. I’m new to this game, so I hadn’t appreciated where the line between WordPress and bbPress might have been drawn. I was trying here largely becasue this website was set up the way I wanted.

    Thanks again for your help though.


    Pete
    Participant

    @uniquepete

    Thanks again @robin-w. Yes, I saw that one. That does work as long as the text that’s being replaced is ‘Howdy’. but that’s language dependent. Down here, if your site is configured for Australia, it’s ‘G’day’ and in other countries I imagine it’s something different again (and that code works as long as you specify the exact string that you need to replace).

    I was actually wanting to get rid of that text altogether, in a language-independent way, so I was hoping that it had a ‘name’, like ‘wp-user-greeting’ or something that you could just do a $wp_adminbar->remove_node on, but it sounds like this is not the case. Is the format of the username/avitar on the admin-bar on this site, where there’s no ‘prefix’ at all, really hard coded (rather than managed through something like a function)?

    I am making progress with the code (to identify a user as anonymous before they log in) from your previous response, so thanks again for that, but I’m modifying files that are bound to be replaced with the next WordPress/bbPress update. There must surely be some ‘version independent’ way of doing this…


    Pete
    Participant

    @uniquepete

    Thanks @robin-w. This (the inclusion of the anonymous user bit) is not just a case of specifying some configuration option on the admin-bar then?

    Is it a similar story then with the way that even the logged in user profile is presented on this site? The standard wp-admin-bar doesn’t seem to offer an option to present just the ‘bare’ username/avatar—I can’t find a way to get rid of the ‘Howdy’ or ‘G’day’ (as I get here in Australia) entirely, like this site does, to present just the username/avatar (I really can’t understand why this isn’t the standard base case). I can find all the language stuff down in wp-content/languages, but I’d really just like to turn off that ‘greeting’ stuff altogether on the admin-bar.

    Thanks again.

Viewing 10 replies - 1 through 10 (of 10 total)