PHP Scripts Development » bbpress plugins and modifications

removing "replies=x" from topic url

(14 posts)

Great offers not only for geeks!


  1. By default bbpress creates some strange URL:

    http ://www. domain.com/forums/topic/some-topic-name?replies=3

    this URL is not really nice and could be a problem because there is a chance that Google will index the same page twice.

    You can fix that while creating a "private" plugin with the following code:
    remove_filter('get_topic_link', 'bb_add_replies_to_topic_link');

    thats all after this your URL's will look better.

    Posted 7 months ago #
  2. This isn't a test :-)

    This snippet works well but breaks the "Quote" plugin which is a very good one to have on a forum with a bit of action.
    ------------------------------------------------------------------

    /*
    Plugin Name: Quote
    Description: Quote message when replying
    Author: Michael Nolan (modified by edwinfoo)
    Version: 0.2
    */
    
    function bb_quote_link($link_text = 'Quote') {
    	global $bb, $page, $topic, $forum, $bb_post;
    	$add = topic_pages_add();
    	if (!topic_is_open( $bb_post->topic_id ) || !bb_is_user_logged_in()) return;
    	$post_id = get_post_id();
    	$last_page = get_page_number( $topic->topic_posts + $add );
    	echo '<a href="'.get_topic_link( 0, $last_page ).'&quote='.$post_id.'#postform">'.__($link_text).'</a>';
    }
    
    function bb_quote_message() {
    		global $bbdb, $topic;
    	$post_id = (int)$_GET['quote'];
    	if ($post_id) {
    		$row = $bbdb->get_row("SELECT * FROM $bbdb->posts INNER JOIN wp_users ON bb_posts.poster_id = wp_users.ID WHERE bb_posts.post_id={$post_id} AND bb_posts.topic_id={$topic->topic_id} AND bb_posts.post_status=0");
    		$row->post_text = rtrim(preg_replace( '(<p>|</p>)', '', $row->post_text ));
    		if ($row) echo htmlentities('
    <blockquote>"'.trim($row->post_text).'"<strong>- '.$row->user_login.'</strong></blockquote>
    ', ENT_COMPAT, 'UTF-8');
    	}
    }
    Posted 7 months ago #
  3. I didn't use the quote plugin (until now), but I will check this thanks.

    btw. great to meet other bbpress user here!

    Posted 7 months ago #
  4. Likewise and it is especially a pleasure to meet people who are concerned with advancing the use of bbPress.

    Olaf, bbBress in it's default state has no blockquote styling which is the basis of quoting. If you implement the plugin on it's own without styling, it won't seem to work.

    Here is the styling I use in style.css

    You can change the colors to anything you want.

    blockquote{
    background-color: transparent;
    border-top: 3px double #ff00ff;
    border-bottom: 3px double #ff00ff;
    padding: 5px;
    line-height: 9pt;
    font-style: oblique;
    font-size: 0.9em;
    margin-left: 5%;
    margin-right: 5%;
    margin-bottom: 0.5em
    }

    Where a topic attracts several posts a day, quoting enables structure to the discussion otherwise it becomes chaotic.

    Also, you need to insert this snippet of code in post.php where you want the quote link to appear.
    <?php bb_quote_link(); ?>

    Posted 7 months ago #
  5. sure your need a quote function in each forum :D

    I tried last night the plugin and noticed the error, thanks for the style suggestion.

    Posted 7 months ago #
  6. OK, I fixed it, use replace the function:

    function bb_quote_link($link_text = 'Quote') {
    	global $bb, $page, $topic, $forum, $bb_post;
    	$add = topic_pages_add();
    	if (!topic_is_open( $bb_post->topic_id ) || !bb_is_user_logged_in()) return;
    	$post_id = get_post_id();
    	$last_page = get_page_number( $topic->topic_posts + $add );
    	$link = get_topic_link( 0, $last_page );
    	$link = add_query_arg( 'quote', $post_id, $link );
    	echo '<a href="'.$link.'#postform" id="quote_'.$post_id.'">'.__($link_text).'</a>';
    }

    He didn't used the bbpress function to create the querystring in his version.

    Posted 7 months ago #
  7. Works perfectly. Thank you. It makes the URL look so much cleaner and now preserves the quote functionality.

    Hmmm, your deployment of the quote plug isn't drawing the username of the original author from the database. Is this deliberate or you using a different quote plugin or somethings gone wrong?

    Posted 7 months ago #
  8. Edwin,
    the standard URLs from bbpress are really BAD for Google! Just imagine google will index your forum everyday (I hope they will), that will say that on your forum page are on two days two different links with the same content ;)

    Posted 7 months ago #
  9. Hmmm, your deployment of the quote plug isn't drawing the username of the original author from the database. Is this deliberate or you using a different quote plugin or somethings gone wrong?

    I downloaded the plugin from the bbress site, is your version from the bbpress forum? (will check this)

    Posted 7 months ago #
  10. Olaf, that could well be the reason that while my URL contains 2 keywords, glam & rock, entering the "glam rock" search string into google finds me on page 5.

    The google dance hasn't been kind to me and it's been getting worse and I suspect the reason is as you said.

    Posted 7 months ago #

RSS feed for this topic

Reply »

You must log in to post.