Info
- 11 posts
- 3 voices
- Started 1 year ago by softinfo
- Latest reply from Ben L.
- This topic is not resolved
Custom forum template like forum-ID.php - possible?
-
- Posted 1 year ago #
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
-
- Posted 1 year ago #
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.phpand edit it as you want to. -
- Posted 1 year ago #
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.phpThank you so much.
-
- Posted 1 year ago #
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; } -
- Posted 1 year ago #
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
-
- Posted 1 year ago #
Bump!... Please help, its really important for me.
-
- Posted 1 year ago #
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.
-
- Posted 1 year ago #
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
-
- Posted 1 year ago #
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.
-
- Posted 1 year ago #
@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? -
- Posted 1 year ago #
That should be fine.
-
You must log in to post.