• Resolved Chuckie

    (@ajtruckle)


    I am using the BBP Style Pack template for my forums. On the main page that lists the categories / forums it is not possible to have a “Create New Topic” button too?

    https://www.publictalksoftware.co.uk/support-forums/

    I notice that here on the bbPress site it does have a button on the front page and on the create topic page you can choose the forum to add your post you.

    I think this would be nice. So clicking the button brings up a new topic form with all the controls etc and a dropdown to choose a forum.

    At the moment the user must click on a forum before they can see the button. TYhat is fine, but the extra method would be nice and might make it clearer to the user how to create a topic.

    Thanks.

Viewing 15 replies - 1 through 15 (of 25 total)
  • tapiohuuhaa

    (@tapiohuuhaa)

    You can create selection box using available hooks:
    This code create Finnish button:
    https://www.sanaristikkofoorumi.net/wordpress/forums/topic/code-snippets-for-this-theme/#post-16559

    I have manually added forum links. Note that this code is replacement for single forum links too. Use just the first if statement!

    if(bbp_is_forum_archive() || bbp_is_single_view()){...}

    in addition you must add these:

    
    add_action( 'bbp_template_before_single_view' , 'topPostLinksEcho');	
    add_action( 'bbp_template_before_forums_index' , 'topPostLinksEcho');

    I have modified some templates and I have used the function differently.

    Thread Starter Chuckie

    (@ajtruckle)

    Thanks. It sounds a little complicated to implement.

    Plugin Author Robin W

    (@robin-w)

    like everything it is doable, but not one I have time for – sorry !

    Thread Starter Chuckie

    (@ajtruckle)

    I understand.

    Thread Starter Chuckie

    (@ajtruckle)

    @tapiohuuhaa Looking at your code it is a hook to echo some HTML section before the forum list. I get that.

    But when they click the button it needs to show a new topic page which has the forum id combo on it. Not sure your code shows that?

    tapiohuuhaa

    (@tapiohuuhaa)

    In practice the pop-up list is manually made list of forums with the anchor #new-post
    .
    When a visitor choose a forum, the links goes to the form, which the visitor can create a new topic to the selected forum. I assume that you mean that. The links don’t have the forum id but the name of the webpage + #new-post

    For example forum id “30” links to the page “Sanaristikot”:

    https://www.sanaristikkofoorumi.net/wordpress/forums/forum/sanaristikot/#new-post

    You don’t need to know the forum id, because the forum id has not been used on the web-address. You need to use the generated name instead if you use the same web-address structure as I have used.

    If you want that WordPress helps you creating forum list, you can use the Add new menu feature.

    Then you need to have amr shortcode any widget plugin installed.

    Next you need to set a new menu widget to Widgets for shortcodes widget area. Look the shortcode, which has this format [do_widget id=nav_menu-X] ( X = number of the menu).

    Then you put into your own code to a suitable place
    echo do_shortcode(‘[do_widget id=nav_menu-X]’);

    Note that you need anyway use Own link feature, because you must add #new-post to the end of the web-address.

    Thread Starter Chuckie

    (@ajtruckle)

    If an admin user edits a topic, it shows a forum combo thus allowing you to move it.

    So I am saying if I have a create button on primary page, which is not confined to a specific forum, it will need this combo. Just like the bbppress forum. Because it has to know where to add the topic too.

    Don’t worry. I leave it.

    tapiohuuhaa

    (@tapiohuuhaa)

    see

    https://www.sanaristikkofoorumi.net/wordpress/forums/

    click “Uusi aihe” ( = “New topic”).

    As I explained you can create the menu also by using Add new menu feature.

    Alternatively you might have opportunity to use some hook(s) to put to the end of each link button “Create new”.

    add_action( ‘bbp_theme_after_forum_title’,’your-extra-features’ );

    Thread Starter Chuckie

    (@ajtruckle)

    Ok. Will check.

    tapiohuuhaa

    (@tapiohuuhaa)

    If you want to add to single view this functionality, you must have in your template an additional hook. The code I put needs this line added to …/content-single-view.php before the div, which has id=”bbpress-forums”.

    <?php do_action('bbp_template_before_single_view'); ?>

    Thread Starter Chuckie

    (@ajtruckle)

    I think I get it now. I suppose in theory I should be able to do a SQL query to pull out the forum names and build that popup list.

    I will have to play in my staging site.

    tapiohuuhaa

    (@tapiohuuhaa)

    Try to use internal functions of bbPress or wordPress. At least you can get forum id:s, apparently also titles.

    But you trial creating a loop might fail because WordPress generates the web-address with its own method. You should also find the function, which converts the name of the title as web-address and you should use it to create a part of the web-address. In the case of sub-forums, you must use it twice in a single web-address. You might need also nested loops

    See for example
    fixed-part-of-the-web-address/sanaristikot/suomen-kuvalehti/

    You would need fist level loop for “sanaristikot/” and if-statement for possible second level loop to get “suomen-kuvalehti/”. The PHP file would be quite complicated!

    Creating a loop you must take account also possible parent-child forum relation, which makes loop more complicated at least if you want to use nested ul and li elements. If you create DIV, you must add class for sub-forums in order to get indents. That makes loop simpler.

    Creating pop-up menu was easy for me because of just few forum. I didn’t need loop neither I didn’t need to use a menu.

    You might have more forums. I recommend you to create a menu for this. You can also set indents for sub-forums easily just putting indents with the menu builder tool.

    Thread Starter Chuckie

    (@ajtruckle)

    Hi @tapiohuuhaa

    You need to bear with me. I added this to the functions.php:

    function topPostLinksEcho() {
    	if(bbp_is_forum_archive() || bbp_is_single_view()) { 
    		echo '<div id="forums-new-topic" class="beforelist beforelist-separate" style="width: 120px!important; display: block!important"><a id="new-data-link" class="open-forum-list subsricption-toggle-new subsricption-toggle-new-topic subscription-toggle" href="#" onclick="return false;"><span>Create New Topic</span></a></div>';
    	}
    }
    add_action( 'bbp_template_before_forums_index' , 'topPostLinksEcho');

    It shows a “Create new Topic” button at the top (not positioned quite how I would like) but it doesn’t do anything. I see you have some script etc too. Do I need that?

    tapiohuuhaa

    (@tapiohuuhaa)

    Look at the page, which address I gave in some previous message (“…code-snippets-for-this-theme/#post-16559“).

    That needs some JavaScript too for open/close functionality + an another add_action in order to create the actual list of forums. Button without JavaScript and HTML code of the function list doesn’t do anything.

    If you want to do that with database queries try to use internal functions of bbPress or wordPress and not direct generic database query functions.

    With internal functions you should get at least forum id:s, apparently also forum titles. You need also parent-child-relation information, if you use child forums.

    But you trial creating a loop might fail because WordPress generates the web-address with its own method. You should also find the function, which converts the name of the title as web-address and you should use it to create a part of the web-address. In the case of sub-forums, you must use it twice in a single web-address. You might need also nested loops

    See for example
    fixed-part-of-the-web-address/sanaristikot/suomen-kuvalehti/

    You would need fist level loop for “sanaristikot/” and if-statement for possible second level loop to get “suomen-kuvalehti/”. The PHP file would be quite complicated!

    Creating a loop you must take account also possible parent-child forum relation, which makes loop more complicated at least if you want to use nested ul and li elements. If you create DIV, you must add class for sub-forums in order to get indents. That makes loop simpler.

    Creating pop-up menu was easy for me because of just few forum. I didn’t need loop neither I didn’t need to use a menu.

    You might have more forums. I recommend you to create a menu for this. You can also set indents for sub-forums easily just putting indents with the menu builder tool.

    tapiohuuhaa

    (@tapiohuuhaa)

    You can put the JavaScript code and the list inside topPostLinksEcho() and you don’t need to add more add_action statements.

    Indeed it is recommend to add JavaScript by using wp_head, when it goes to the HEAD-section of the page.

Viewing 15 replies - 1 through 15 (of 25 total)
  • The topic ‘Creating New Topics’ is closed to new replies.