Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results Item Header Info


  • Pete
    Participant

    @uniquepete

    Hi,

    I’m trying to add some detail to search results associated with replies to topics. By default, it would seem that if a search finds a hit in a particular topic post, it includes the name of the topic and the relevant forum in the header for the particular search result:
    Default Topic Result Header
    In contrast, a hit on a reply to a particular topic does not include any topic or forum information: Default Reply Result Header

    I thought I might be able to solve my problem by modifying the loop-search-reply.php template to include what looked like it might be the relevant code from the loop-search-topic.php template:

    
    <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>"><?php bbp_forum_title( bbp_get_topic_forum_id() ); ?></a>
    
    </div><!-- .bbp-topic-title-meta -->
    
    <?php do_action( 'bbp_theme_after_topic_title' ); ?>
    

    but it seems that was a little naive of me. This block of code certainly includes what could be the required information:Modified Reply Result Header but what I thought would be inserted as the forum name turns out to be the topic name.

    Looking at the above code, I can see why this might be—the relevant text, ‘bbpress’, in the code block above appears to be just some placeholder text, and is the same placeholder text used to reference the topic name. I had thought that the text replacement might be a little more context sensitive than it appears to be.

    So my question is, can anyone tell me how that text (‘bbpress’ in the above code segment, which is taken directly from the default loop-search-topic.php template) gets replaced, or more specifically I guess, can anyone tell me where to inject a function or the like to set this or some other piece of placeholder text (I appreciate that it may need to be different to the placeholder text being used for the topic name) to the relevant forum name?

    Thanks

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

  • 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

    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

    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' ); ?>
    
Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Skip to toolbar