Notifications
Clear all

Suggestion [Closed] Add "Search in Topic"

5 Posts
3 Users
4 Likes
3,103 Views
Posts: 11
Topic starter
(@nick81)
Eminent Member
Joined: 1 year ago

Hi, is it possible to add an "Search in this topic" function? I can use the customization of the theme, but I need an api (wpft) to search for posts with topicid.

You can check my forum with active search function

Needed changes:

classes/Post.php

942 > topicids'    => [],         // array( 2, 10, 25 )
969 > if( $args['topicids'] ) $wheres[] = $fa . ".`topicid` IN(" . implode( ', ', array_map( 'intval', $args['topicids'] ) ) . ")";

wpforo.php

965 > 'topicids'    => (array) wpfval( $get, 'wpft' ),

themes/x/post.php

e.g. at line 13 >
  <form action="<?php echo wpforo_home_url() ?>" method="get">
            <?php wpforo_make_hidden_fields_from_url( wpforo_home_url() ) ?>
            <input name="wpfs" type="text" value>
            <input name="wpft" type="hidden" value="<?php echo $topic['topicid'] ?>">
            <input type="submit" value="Im Beitrag suchen">
   </form>
4 Replies
Tutrix
Posts: 1246
(@tutrix)
Noble Member
Joined: 4 years ago

Hi @nick81

good idea, I modified the code a little bit 😉 

so the search box will be displayed only above the first post "in all layouts"

    <div class="wpf-topic-search">
      <?php if( $post['is_first_post'] ): ?>
      <form action="<?php echo wpforo_home_url() ?>" method="get">
      <?php wpforo_make_hidden_fields_from_url( wpforo_home_url() ) ?>
      <input name="wpfs" type="text" value>
      <input name="wpft" type="hidden" value="<?php echo $topic['topicid'] ?>">
      <input type="submit" value="Im Thema suchen">
      </form>
      <?php endif; ?>
    </div>

and with css you can customize the field

example

#wpforo #wpforo-wrap .wpf-topic-search {margin: 5px auto !important; width: 100%; text-align: center;}
#wpforo #wpforo-wrap .wpf-topic-search input[type="text"]{border-radius: 5px;}
#wpforo #wpforo-wrap .wpf-topic-search input[type="submit"]{border-radius: 5px !important; line-height: 15px;}
1 Reply
(@nick81)
Joined: 1 year ago

Eminent Member
Posts: 11

@tutrix Thanks for reply. In which file put you the form? Or does this mean, that my suggestion will be released in near future? Then I'll wait for the release 🙂

 

I have some additional suggestions. Is there a repo out there? Or should I write suggestions here in forum?

(first/last site nav, notification mail/bell adjustable ...)

Tutrix
Posts: 1246
(@tutrix)
Noble Member
Joined: 4 years ago

Posted by: @nick81

In which file put you the form? Or does this mean, that my suggestion will be released in near future?

i am not one of the developers of wpForo 😉 , so i have also added the form to the post.php of each layout

Chris
Posts: 3650
(@chris)
Famed Member
Joined: 3 years ago

Hi @nick81 and @tutrix,

Thanks for the good work,

I have sent the suggestion on "Search in Topics" Functionality for consideration.