Skip to:
Content
Pages
Categories
Search
Top
Bottom

External page submit form (get topic id)


  • piccart
    Participant

    @piccart

    Hello!

    I am using the default template of bbpress and I’d like to customize it

    My issue is divisible in 3 parts:

    1- I’d like to cut off the “add your reply form” from the bottom of the comments list
    2- I’d like to make a custom page with the form, which I’ve seen I can make with a shortcode
    3- I’ll need to build up a button “post reply” on the topic page, which I think it will have to pass to the form page a variable with the id of the topic, otherwise it won’t be possible for that form to append the reply to the correct topic, isn’t it?

    I think I’ve found where to cut off the displaying of the form but I’d like you to confirm before I make mess. is it in this file:
    bbpress/templates/default/bbpress/content-single-topic.php
    and if I’d like to cut off the form from the topics archive lists as well, the file should be this:
    bbpress/templates/default/bbpress/content-single-forum.php

    point 2 should be easy, but I am wondering how I’ll have to pass the variable of the topic which has to be commented.. anyone can explain me how this works?

    in point 3 I have no idea.. I’ve browsed millions of files today and found millions of functions and hooks so I don’t know which I have to use and how. by instance I’ve found a bb_get_forum_id() and a get_forum_id() and who knows if there are more similar that I’ve missed. which has to be used to retrive the current topic id? and how it has to be used?

    Thank you very much for reading this topic, I hope someone will help me.
    Cheers!
    Andrea

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

  • piccart
    Participant

    @piccart

    ok, I’ve figured it out.

    the files which have to be edited are:
    bbpress/templates/default/bbpress/content-single-forum.php
    bbpress/templates/default/bbpress/content-single-topic.php

    in the first one you’ll have to cut off this line in each place it comes:
    <?php bbp_get_template_part( 'form', 'topic' ); ?>

    and substitute with something like this, to make the new-topic link:
    <a href="http://mywebsite.com/form-new-topic/?forum_id=<?php bbp_forum_id(); ?>

    then you create a new template page (which you’ll assign to a page called “Form New Topic”) copying your theme default page, and adding at the top /* Template Name: Form New Topic */ . then you can substitute the function which displays the content, or just add this below it:

    $forum_id = $_GET['forum_id'];
    echo do_shortcode("[bbp-topic-form forum_id=$forum_id]");

    at the same you can edit the second file (the topics list) substituting this:
    <?php bbp_get_template_part( 'form', 'reply' ); ?>

    with something like this:
    <a href="http://mywebsite.com/form-new-reply/?topic_id=<?php bbp_topic_id(); ?>

    and then create a new template called “Form New Reply”, and add a code similar to the other one but using the shortcode to display the reply form. unfortunately the shortcode for the reply form seems to don’t have a topic id attribute, according to this list: https://codex.bbpress.org/shortcodes/

    I’ll make some test to see how it react, the only other solution I see is to make a spoiler with the reply form, so it’s hidden till you click.

    p.s. you can also store the ids into variables, using these functions:

    $forum_id = bbp_get_forum_id();
    $topic_id = bbp_get_topic_id();

    hochingj
    Participant

    @hochingj

    Thanks for posting this! Can you show us the result? I am trying to do the same thing. I want to have a “start a new topic” on the forum list page and have them choose the category from a dropdown list.

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