Skip to:
Content
Pages
Categories
Search
Top
Bottom

“Custom” rewrite rule for static pages

  • I’m working right now on Static Pages plugin (and y’know what? It’s working!) but I want to include working mod_rewrite for them, so with active MultiViews I will be able to type domain.com/page/about/ for example.

    But – I have no idea where to look for any functions, options or anything that might help me in discovering “how the heck to make this?” Any advices?

Viewing 1 replies (of 1 total)
  • I’ve created something like this:

    function page_link( $page_number ) {
    echo apply_filters('page_link', get_page_link( $page_number ) );
    }

    function get_page_link( $page_number ) {
    $rewrite = bb_get_option( 'mod_rewrite' );
    if ( $rewrite ) {
    global $bbdb, $bb, $page;
    $page = $page_number;

    if ( $rewrite === 'slugs' ) {
    $table_name = $bbdb->prefix . "pages";
    $query = $bbdb->get_results("SELECT page_slug FROM $table_name WHERE page_id=".$page."");

    foreach ($query as $rk) {
    $column = $rk->page_slug;
    }
    } else {
    $table_name = $bbdb->prefix . "pages";
    $query = $bbdb->get_results("SELECT page_id FROM $table_name WHERE page_id=".$page."");

    foreach ($query as $rk) {
    $column = $rk->page_id;
    }
    }
    $link = bb_get_option( 'uri' ) . "page/" . $column;
    } else {
    $args = array();
    $link = bb_get_option( 'uri' ) . 'page.php';
    $args['page_id+id'] = $page;
    $args['part'] = 1 < $part ? $part : false;
    $link = add_query_arg( $args, $link );
    }

    return apply_filters( 'get_page_link', $link, $page_number );
    }

    Trust me, I don’t know what this is either ;). I’m working on this for a couple of hours (in total) and I’ve messed up. Could someone help me in this by explaining how this thing should look like?

    I mean – the above code is allowing me to type

    <?php echo page_link("1"); ?>

    and this will display url to static page with id=1, creating something like domain.com/page/1 or domain.com/page/about – so links are working. But now I want to send page ID to other functions that are selecting and displaying date from database – and I have no idea how to send this id in ‘rewrited’ version. Can anyone help?

Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.