Skip to:
Content
Pages
Categories
Search
Top
Bottom

Need Permalinks in bbpages plugin? SEO Friendly

  • Dear Developers,

    I’ve recently use bbpages plugin.. its working fine..but i want one more thing in this plugin … here is url like my site

    http://www.example.com/bb-page.php?page_id=3

    i want to change it to

    http://www.example.com/my-own-keyword.html

    can any coder tell me how it possible?

    i’ll be great thankful to you

    here is plugins files


    1. bb-page.php for root

    <?php

    require_once(‘./bb-load.php’);

    $page_id = 0;

    bb_repermalink();

    if ( !$page )

    bb_die(__(‘Page not found.’));

    do_action( ‘bb-page.php’, $page_id );

    bb_load_template( ‘page.php’, array(‘bb_db_override’, ‘page_id’) );

    ?>


    2. page.php for template

    <?php bb_get_header(); ?>

    <?php if ( isset_id() ) : ?><?php if ( page_exist() ) : // Do not delete this ?>

    <div class=”top_box”>

    <h2><?php echo get_page_title(); ?></h2>

    <div class=”bbcrumb”>“><?php bb_option(‘name’); ?> » <?php echo get_page_title(); ?></div>

    </div>

    <div class=”post-content”>

    <?php echo get_page_content(); ?>

    </div>

    <?php else: // If there is no page with id=X in database ?>

    <div class=”notice_box”><div class=”notice_content”>404 – I’m sorry, but this page does not exist.</div></div>

    <?php endif; ?>

    <?php else: // If page ID is not specified or it equals 0 ?>

    <div class=”notice_box”><div class=”notice_content”>Page is not specified.</div></div>

    <?php endif; ?>

    <?php bb_get_footer(); ?>


    3. bb-pages.php for plugin

    <?php

    /*

    Plugin Name: bbPages

    Plugin URI: http://astateofmind.eu/freebies/bbpages/

    Description: Allows you to create static pages within your bbPress forum.

    Author: F.Thion

    Author URI: http://astateofmind.eu

    Version: 0.0.2

    license: GPL

    donate: http://astateofmind.eu/about/support/

    */

    function get_page_id() {

    if ( isset ( $_GET ) ) :

    $page_id = $_GET;

    return $page_id;

    endif;

    }

    function isset_id() {

    if ( $_GET > 0 ) :

    return true;

    else:

    return false;

    endif;

    }

    function page_exist() {

    global $bbdb, $bb;

    $id = get_page_id();

    $table_name = $bbdb->prefix . “pages”;

    $query = $bbdb->get_results(“SELECT page_id FROM $table_name WHERE page_id=”.$id.””);

    if ( $query == true ) :

    return true;

    else:

    return false;

    endif;

    }

    function get_page_title() {

    global $bbdb, $bb, $page_id;

    $id = get_page_id();

    $table_name = $bbdb->prefix . “pages”;

    $query = $bbdb->get_results(“SELECT page_title FROM $table_name WHERE page_id=”.$id.””);

    foreach ($query as $rk) {

    return $rk->page_title;

    }

    }

    function get_page_slug() {

    global $bbdb, $bb, $page_id, $page;

    $id = get_page_id();

    $table_name = $bbdb->prefix . “pages”;

    $query = $bbdb->get_results(“SELECT page_slug FROM $table_name WHERE page_id=”.$id.””);

    foreach ($query as $rk) {

    return $rk->page_slug;

    }

    }

    function get_page_content() {

    global $bbdb, $bb, $page_id;

    $id = get_page_id();

    $table_name = $bbdb->prefix . “pages”;

    $query = $bbdb->get_results(“SELECT page_content FROM $table_name WHERE page_id=”.$id.””);

    foreach ($query as $rk) {

    return $rk->page_content;

    }

    }

    function list_pages() {

    global $bbdb, $bb;

    $table_name = $bbdb->prefix . “pages”;

    $query = $bbdb->get_results(“SELECT * FROM $table_name ORDER BY page_order ASC”);

    $status = array(

    0 => ‘Draft’,

    1 => ‘Published’

    );

    foreach ($query as $rk) {

    echo ‘

    <tr>

    <td>’.$rk->page_id.'</td>

    <td>’.$rk->page_title.'</td>

    <td>’.$rk->page_date.'</td>

    <td>’.$status[$rk->page_status].'</td>

    <td>page_id.'”>Edit | page_id.'”>Delete | page_id.'”>View</td>

    </tr>

    ‘;

    }

    }

    function pages_panel() {

    $action = $_REQUEST;

    switch($action)

    {

    default:

    ?>

    <h2>Manage Static Pages <small>(Create new page)</small></h2>

    <table class=”widefat”>

    <thead>

    <tr>

    <th style=’width:5%;’>ID</th>

    <th style=’width:45%;’>Title</th>

    <th style=’width:20%;’>Creation Date</th>

    <th style=’width:10%;’>Status</th>

    <th style=’width:20%;’>Actions</th>

    </tr>

    </thead>

    <tbody>

    <?php echo list_pages(); ?>

    </tbody>

    </table>

    <h3>Please support the developer</h3>

    <img src=”http://astateofmind.eu/uploads/donation.gif&#8221; style=”margin-right:10px” border=”0″ align=”left” />

    Do you like this plugin? Do you find it useful? If so, please donate few dollars so I could keep develop this plugin and others further and further. Even the smallest help is greatly appreciated for a student in Poland ;).

    <form action=”https://www.paypal.com/cgi-bin/webscr&#8221; method=”post”>

    <input type=”hidden” name=”cmd” value=”_donations”>

    <input type=”hidden” name=”business” value=”wojciech.usarzewicz@gmail.com”>

    <input type=”hidden” name=”item_name” value=”bbPages Donation”>

    <input type=”hidden” name=”item_number” value=”bbPages Donation”>

    <input type=”hidden” name=”no_shipping” value=”0″>

    <input type=”hidden” name=”no_note” value=”1″>

    <input type=”hidden” name=”currency_code” value=”USD” />

    Type donation amount: $ <input type=”text” name=”amount” value=”1″ />

    <input type=”hidden” name=”tax” value=”0″>

    <input type=”hidden” name=”lc” value=”US”>

    <input type=”hidden” name=”bn” value=”PP-DonationsBF”>

    <input type=”submit” name=”submit” value=”Donate with PayPal!” alt=”PayPal – The safer, easier way to pay online!”>

    <img alt=”” border=”0″ src=”https://www.paypal.com/pl_PL/i/scr/pixel.gif&#8221; width=”1″ height=”1″>

    </form>

    <p>Want to know what I’m developing right now? Follow me on Twitter, ignore 90% of stuff and learn a lot you will ;). And thank you for using my plugin!</p>

    <?php

    break;

    case “add”:

    global $bbdb, $bb;

    if (isset($_POST))

    {

    $page_title = $_POST;

    $page_slug = bb_sanitize_with_dashes( “$page_title”, “” );

    $page_content = $_POST;

    $page_order = $_POST;

    $page_status = $_POST;

    $table_name = $bbdb->prefix . “pages”;

    $query = “INSERT INTO ” . $table_name .

    ” (page_id, page_date, page_content, page_title, page_status, page_slug, page_order) ” .

    “VALUES (0, NOW(), ‘”.$page_content.”‘, ‘”.$page_title.”‘, ‘”.$page_status.”‘, ‘”.$page_slug.”‘, ‘”.$page_order.”‘)”;

    $bbdb->query($query);

    ?><div class=”updated”><p>Page has been saved.</p></div> <?php

    }

    ?>

    <h2>Add new page</h2>

    <form class=”settings” method=”post”>

    <fieldset>

    <div>

    <label for=”page_title”>

    Page title </label>

    <div>

    <input name=”page_title” id=”page_title” type=”text” class=”text long” />

    <p>Page slug will be created automatically (don’t worry, it’s not useful for anything yet).</p>

    </div>

    </div>

    <div>

    <label for=”page_order”>

    Page order </label>

    <div>

    <input name=”page_order” id=”page_order” type=”text” class=”text long” />

    </div>

    </div>

    <div>

    <label for=”page_content”>

    Page content </label>

    <div>

    <textarea name=”page_content” id=”page_content” rows=”20″ cols=”80″ ></textarea>

    </div>

    </div>

    <input type=”hidden” name=”page_status” value=”1″ />

    <input type=”hidden” name=”page_id” value=”<?php echo $_GET; ?>” />

    </fieldset>

    <input type=”submit” class=”submit” name=”add_page” value=”<?php _e(‘Add page’, ‘add_page’) ?>” />

    </form>

    <?php

    break;

    case “edit”:

    global $bbdb, $bb;

    if (isset($_POST)) {

    $page_id = $_POST;

    $page_title = $_POST;

    $page_content = $_POST;

    $page_order = $_POST;

    $page_status = $_POST;

    $table_name = $bbdb->prefix . “pages”;

    $query = “UPDATE “.$table_name.” SET page_content='”.$page_content.”‘, page_title='”.$page_title.”‘, page_status='”.$page_status.”‘, page_order='”.$page_order.”‘ WHERE page_id='”.$page_id.”‘”;

    $bbdb->query($query);

    ?> <div class=”updated”><p>Page updated…</p></div> <?php

    }

    $table_name = $bbdb->prefix . “pages”;

    $query = $bbdb->get_results(“SELECT * FROM $table_name WHERE page_id=”.$_GET.””);

    foreach ($query as $rk) {

    $id = $rk->page_id;

    $title = $rk->page_title;

    $content = $rk->page_content;

    $order = $rk->page_order;

    $status = $rk->page_status;

    }

    ?>

    <h2>Edit page</h2>

    <form class=”settings” method=”post”>

    <fieldset>

    <div>

    <label for=”page_title”>

    Page title </label>

    <div>

    <input name=”page_title” id=”page_title” type=”text” class=”text long” value=”<?php echo “$title”; ?>” />

    <p>Page slug will be created automatically (don’t worry, it’s not useful for anything yet).</p>

    </div>

    </div>

    <div>

    <label for=”page_order”>

    Page order </label>

    <div>

    <input name=”page_order” id=”page_order” type=”text” class=”text long” value=”<?php echo “$order”; ?>” size=”10″ />

    </div>

    </div>

    <div>

    <label for=”page_content”>

    Page content </label>

    <div>

    <textarea name=”page_content” id=”page_content” rows=”20″ cols=”80″ ><?php echo “$content”; ?></textarea>

    </div>

    </div>

    <input type=”hidden” name=”page_status” value=”1″ />

    <input type=”hidden” name=”page_id” value=”<?php echo $_GET; ?>” />

    </fieldset>

    <input type=”submit” class=”submit” name=”save_page” value=”<?php _e(‘Save page’, ‘save_page’) ?>” />

    </form>

    <?php

    break;

    case “delete”:

    global $bbdb, $bb;

    $id = $_GET;

    $table_name = $bbdb->prefix . “pages”;

    $query = $bbdb->get_results(“DELETE FROM $table_name WHERE page_id=”.$_GET.””);

    $bbdb->query($query);

    ?> <div class=”updated”><p>Page deleted…</p></div> <?php

    break;

    }

    }

    function pages_admin_menu() {

    bb_admin_add_menu(__(‘Manage Pages’), ‘administrate’, ‘pages_panel’);

    }

    function bbpages_install() {

    global $bbdb;

    $table_name = $bbdb->prefix . “pages”;

    $bbdb->query(“CREATE TABLE IF NOT EXISTS $table_name (

    page_id mediumint(9) NOT NULL AUTO_INCREMENT,

    page_date datetime,

    page_content text,

    page_title varchar(255),

    page_status int(1),

    page_slug varchar(255),

    page_order int(11),

    PRIMARY KEY (page_id)

    )”);

    }

    bb_register_activation_hook( __FILE__, ‘bbpages_install’);

    add_action( ‘bb_admin_menu_generator’, ‘pages_admin_menu’ );

    ?>


    Note: I want to mention here that the author of this plugin is no more active. He make this plugin but something is wrong with this pluing. he tell us wrong path for plugins files. But I’ve little bit knowledge of php that’s why i correct its path now the path of the plugins files which I’ve mentioned above is totally correct and working fine.

    Now I really need to your help. If someone will not guide me then I’ll leave this software “bbpress” and I’ll move to vBulletin or phpbb after disheart….

    So I’m waiting for positive answers from developers… Thanks … And Love you all

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

  • Michael
    Participant

    @michael888

    Unfortunately, this plugin was meant to have support for Permalinks – hence the unused Page slug in the bbPages settings – but that never came about.

    I recently had this problem too – so I manually edited my .htaccess file in the bbPress root.

    So, I turned my Rules page from this:

    http://www.inniosoft.co.cc/devstation/bb-page.php?page_id=1

    to

    http://www.inniosoft.co.cc/devstation/rules/

    You need to open your .htaccess file in the bbPress root and add the following for each page, replacing <your-page> with the url you would like:

    RewriteRule ^<your-page>/?$ /bb-page.php?page_id=1 [L]

    please send me complete code… i can’t understand it…

    of if you can send me .htaccess file then i’ll be happy

    and also tell me where i put this .htaccess file because i’ve integrated my wordpress and bbpress

    so where should i put this file… wordpress root or bbpress root?


    Michael
    Participant

    @michael888

    The file should already exist in your bbPress Root.

    Mine looks like this:

    # BEGIN bbPress

    Options -MultiViews

    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteBase /devstation/

    RewriteRule ^rules/?$ /devstation/bb-page.php?page_id=1 [L]
    RewriteRule ^faq/?$ /devstation/bb-page.php?page_id=2 [L]

    RewriteRule ^page/([0-9]+)/?$ /devstation/index.php?page=$1 [L,QSA]
    RewriteRule ^forum/([^/]+)/page/([0-9]+)/?$ /devstation/forum.php?id=$1&page=$2 [L,QSA]
    RewriteRule ^forum/([^/]+)/?$ /devstation/forum.php?id=$1 [L,QSA]
    RewriteRule ^forum/?$ /devstation/ [R=302,L,QSA]
    RewriteRule ^topic/([^/]+)/page/([0-9]+)/?$ /devstation/topic.php?id=$1&page=$2 [L,QSA]
    RewriteRule ^topic/([^/]+)/?$ /devstation/topic.php?id=$1 [L,QSA]
    RewriteRule ^topic/?$ /devstation/ [R=302,L,QSA]
    RewriteRule ^tags/([^/]+)/page/([0-9]+)/?$ /devstation/tags.php?tag=$1&page=$2 [L,QSA]
    RewriteRule ^tags/([^/]+)/?$ /devstation/tags.php?tag=$1 [L,QSA]
    RewriteRule ^tags/?$ /devstation/tags.php [L,QSA]
    RewriteRule ^profile/([^/]+)/page/([0-9]+)/?$ /devstation/profile.php?id=$1&page=$2 [L,QSA]
    RewriteRule ^profile/([^/]+)/([^/]+)/?$ /devstation/profile.php?id=$1&tab=$2 [L,QSA]
    RewriteRule ^profile/([^/]+)/([^/]+)/page/([0-9]+)/?$ /devstation/profile.php?id=$1&tab=$2&page=$3 [L,QSA]
    RewriteRule ^profile/([^/]+)/?$ /devstation/profile.php?id=$1 [L,QSA]
    RewriteRule ^profile/?$ /devstation/profile.php [L,QSA]
    RewriteRule ^view/([^/]+)/page/([0-9]+)/?$ /devstation/view.php?view=$1&page=$2 [L,QSA]
    RewriteRule ^view/([^/]+)/?$ /devstation/view.php?view=$1 [L,QSA]
    RewriteRule ^rss/?$ /devstation/rss.php [L,QSA]
    RewriteRule ^rss/topics/?$ /devstation/rss.php?topics=1 [L,QSA]
    RewriteRule ^rss/forum/([^/]+)/?$ /devstation/rss.php?forum=$1 [L,QSA]
    RewriteRule ^rss/forum/([^/]+)/topics/?$ /devstation/rss.php?forum=$1&topics=1 [L,QSA]
    RewriteRule ^rss/topic/([^/]+)/?$ /devstation/rss.php?topic=$1 [L,QSA]
    RewriteRule ^rss/tags/([^/]+)/?$ /devstation/rss.php?tag=$1 [L,QSA]
    RewriteRule ^rss/tags/([^/]+)/topics/?$ /devstation/rss.php?tag=$1&topics=1 [L,QSA]
    RewriteRule ^rss/profile/([^/]+)/?$ /devstation/rss.php?profile=$1 [L,QSA]
    RewriteRule ^rss/view/([^/]+)/?$ /devstation/rss.php?view=$1 [L,QSA]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^.*$ /devstation/index.php [L]
    </IfModule>

    # END bbPress

    Most of those should already be there. I have separated the two rules at the top so you can see how it is done for pages.

    If your site has a forum directory (ie the forum does not reside on the top-level of your site, then you should remove the “devstation/”. If it does, then replace “devstation/” with your forum’s directory.

    Regards

    Michael

    Finally i got it…..Thanks a lot…. Michael You are really a Gooooooooooooood Person :-)


    Michael
    Participant

    @michael888

    I’m glad it worked :) I’d probably want to find a way to enhance the plugin, but I don’t think I will as bbPress is soon to be changed. We had our first-ever IRC last night, and some major developments are going to come out of it – including things that have not yet been mentioned. So there’d be no point developing a plugin for an old version of bbPress.

    :)

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.
Skip to toolbar