Skip to:
Content
Pages
Categories
Search
Top
Bottom

Custom forum template like forum-ID.php – possible?


  • Pomy
    Participant

    @softinfo

    I’m searching a method to customize some forums and Sub-forums separately.

    Something like WordPress Template Hierarchy. Which says,

    In the case of categories, the hierarchy is fairly simple. For instance, suppose the slug of the Category in question is default and the Category ID is 6. The Template Hierarchy specifies that WordPress will use the first Template file it finds in your current Theme’s directory from the following list:

    category-slug.php (Note: available with Version 2.9)

    category-ID.php

    category.php

    archive.php

    index.php

    That is, if you do not have a category-slug.php (lets say category-news.php), WordPress will check for a category-ID.php (like category-6.php), and so on.

    Did bbPress have this function? How can I get this?

    Can I make a separate template file for a separate forum?

    Thanks

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

  • Ben L.
    Member

    @nightgunner5

    I don’t think bbPress can do this in its current version (IIRC), but what you can do is put something like this at the top of your forum template:

    if ( get_forum_id() == 7 ) {
    bb_load_template( 'forum-7.php' );
    return;
    }

    And then copy the forum template (minus the added lines) to forum-7.php and edit it as you want to.


    Ben L.
    Member

    @nightgunner5

    I don’t think bbPress can do this in its current version (IIRC), but what you can do is put something like this at the top of your forum template:

    if ( get_forum_id() == 7 ) {
    bb_load_template( 'forum-7.php' );
    return;
    }

    And then copy the forum template (minus the added lines) to forum-7.php and edit it as you want to.


    Pomy
    Participant

    @softinfo

    Ben L. Great Tip :)

    It works… One more question..

    Is it possible to make file name according to forum name/slug?

    Its now…. forum-ID.php >> forum-7.php

    I want….. forum-slug/name.php >> forum-myforum.php

    Thank you so much.


    Pomy
    Participant

    @softinfo

    Ben L. Great Tip :)

    It works… One more question..

    Is it possible to make file name according to forum name/slug?

    Its now…. forum-ID.php >> forum-7.php

    I want….. forum-slug/name.php >> forum-myforum.php

    Thank you so much.


    Ben L.
    Member

    @nightgunner5

    You could use the same method with a little tweak:

    $forum = bb_get_forum();
    if ( $forum->forum_slug == 'myforum' ) {
    bb_load_template( 'forum-myforum.php' );
    return;
    }


    Ben L.
    Member

    @nightgunner5

    You could use the same method with a little tweak:

    $forum = bb_get_forum();
    if ( $forum->forum_slug == 'myforum' ) {
    bb_load_template( 'forum-myforum.php' );
    return;
    }


    Pomy
    Participant

    @softinfo

    Hi Ben L.

    I’m sorry, second code is not working from my side.

    Are you sure about this code?

    Please tell me where I’m wrong.

    Error:

    Warning: Missing argument 1 for bb_get_forum(), called in /home/domain/public_html/my-domain.com/forum/bb-templates/bbp-template/forum.php on line 18 and defined in /home/domain/public_html/my-admin.com/forum/bb-includes/functions.bb-forums.php on line 125

    `

    Thanks


    Pomy
    Participant

    @softinfo

    Hi Ben L.

    I’m sorry, second code is not working from my side.

    Are you sure about this code?

    Please tell me where I’m wrong.

    Error:

    Warning: Missing argument 1 for bb_get_forum(), called in /home/domain/public_html/my-domain.com/forum/bb-templates/bbp-template/forum.php on line 18 and defined in /home/domain/public_html/my-admin.com/forum/bb-includes/functions.bb-forums.php on line 125

    `

    Thanks


    Pomy
    Participant

    @softinfo

    Bump!… Please help, its really important for me.


    Pomy
    Participant

    @softinfo

    Bump!… Please help, its really important for me.


    zaerl
    Participant

    @zaerl

    No no no.

    /forum.php, near the end:

    $template = 'forum.php';
    if($forum->forum_slug == 'this') $template = 'whatever-you-want.php';
    else if($forum->forum_slug == 'that') $template = 'something-else.php';

    bb_load_template( $template, array('bb_db_override', 'stickies'), $forum_id );

    /topic.php, near the end:

    $template = 'topic.php';
    $forum = bb_get_forum($topic->forum_id);
    if($forum->forum_slug == 'this') $template = 'whatever-you-want.php';
    else if($forum->forum_slug == 'that') $template = 'something-else.php';

    bb_load_template( $template, array('bb_db_override', 'stickies'), $forum_id );

    Keep in mind that this is a rude approach and that everything can be packed in a plugin.


    zaerl
    Participant

    @zaerl

    No no no.

    /forum.php, near the end:

    $template = 'forum.php';
    if($forum->forum_slug == 'this') $template = 'whatever-you-want.php';
    else if($forum->forum_slug == 'that') $template = 'something-else.php';

    bb_load_template( $template, array('bb_db_override', 'stickies'), $forum_id );

    /topic.php, near the end:

    $template = 'topic.php';
    $forum = bb_get_forum($topic->forum_id);
    if($forum->forum_slug == 'this') $template = 'whatever-you-want.php';
    else if($forum->forum_slug == 'that') $template = 'something-else.php';

    bb_load_template( $template, array('bb_db_override', 'stickies'), $forum_id );

    Keep in mind that this is a rude approach and that everything can be packed in a plugin.


    Pomy
    Participant

    @softinfo

    Hi Zaerl, Thanks for your interest in this topic :)

    I also tried your method, but I’m sorry its little bit different.

    its shows content from “whatever-you-want.php” when slug is “this” but the forum structure remain same.

    something like

    **************Forum Template**************

    — Default Header

    — Default latest discussion

    — Default forums

    — Default Footer

    — Custom content from whatever-you-want.php

    ********************************************

    But I’m searching, that when forum slug is “this” then i can handle every thing from scratch from “whatever-you-want.php”

    like

    *************Forum Template***************

    — My Custom Header for forum slug “this”

    — My Custom latest discussion

    — My Custom forums categories

    — My Custom style for footer

    *******************************************

    Keep in mind that this is a rude approach and that everything can be packed in a plugin.

    I’m afraid what you are talking about. Is this not a secure method?

    Can you please pack this code into a plugin, I’ll really appreciate your kindness. Thanks


    Pomy
    Participant

    @softinfo

    Hi Zaerl, Thanks for your interest in this topic :)

    I also tried your method, but I’m sorry its little bit different.

    its shows content from “whatever-you-want.php” when slug is “this” but the forum structure remain same.

    something like

    **************Forum Template**************

    — Default Header

    — Default latest discussion

    — Default forums

    — Default Footer

    — Custom content from whatever-you-want.php

    ********************************************

    But I’m searching, that when forum slug is “this” then i can handle every thing from scratch from “whatever-you-want.php”

    like

    *************Forum Template***************

    — My Custom Header for forum slug “this”

    — My Custom latest discussion

    — My Custom forums categories

    — My Custom style for footer

    *******************************************

    Keep in mind that this is a rude approach and that everything can be packed in a plugin.

    I’m afraid what you are talking about. Is this not a secure method?

    Can you please pack this code into a plugin, I’ll really appreciate your kindness. Thanks


    zaerl
    Participant

    @zaerl

    What you’re asking for involve hooking the “bb_get_active_theme_directory” filter (or similar):

    function custom_dir($directory)
    {
    // do something
    // append the slug for example
    global $forum;
    $directory .= $forum->forum_slug . '/'
    }

    if(special case described in my last post) add_filter( 'bb_get_active_theme_directory', 'custom_dir');

    I’m sorry but I can’t help you further, I’m pretty busy right now.


    zaerl
    Participant

    @zaerl

    What you’re asking for involve hooking the “bb_get_active_theme_directory” filter (or similar):

    function custom_dir($directory)
    {
    // do something
    // append the slug for example
    global $forum;
    $directory .= $forum->forum_slug . '/'
    }

    if(special case described in my last post) add_filter( 'bb_get_active_theme_directory', 'custom_dir');

    I’m sorry but I can’t help you further, I’m pretty busy right now.


    Pomy
    Participant

    @softinfo

    @zaerl

    I’m sorry but I can’t help you further, I’m pretty busy right now.

    Ahh Ok, But I’m not able to hire someone for “complete” help.

    Any way thanks for your help.

    @Ben L. – I tried

    if ( $forum->forum_slug == 'myforum' ) {
    bb_load_template( 'forum-myforum.php' );
    return;
    }

    It works, can I use this method removing $forum = bb_get_forum(); ??

    Is it secure?


    Pomy
    Participant

    @softinfo

    @zaerl

    I’m sorry but I can’t help you further, I’m pretty busy right now.

    Ahh Ok, But I’m not able to hire someone for “complete” help.

    Any way thanks for your help.

    @Ben L. – I tried

    if ( $forum->forum_slug == 'myforum' ) {
    bb_load_template( 'forum-myforum.php' );
    return;
    }

    It works, can I use this method removing $forum = bb_get_forum(); ??

    Is it secure?


    Ben L.
    Member

    @nightgunner5

    That should be fine.


    Ben L.
    Member

    @nightgunner5

    That should be fine.

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