I found two things in Advanced forum.

1. Advanced forum provides the views, one of which is advanced forum search as shown in the following image, which provide the specific search on the forum.

Advanced forum search view

2. But it is a separate link, and totally separate page, if it will be under the title of the advanced forum topic and on every forum discussion page, it will be very suitable for visitors. As shown in this image.

needed search form at top, under the title

Now, how to add that advanced forum box and advanced option selection box provided in views under the forum title? I mean all on all the pages of forum except the first main page. Very Thanks.

1 Answer 1


You need to display the exposed filters in a block, and then display that block on single forum node pages.

Here's how to do that:

  1. Edit the Forum Search view: /admin/structure/views/view/advanced_forum_search/edit.
  2. Under "Exposed form" -> "Exposed form in block" choose "Yes".
  3. Save the view.
  4. Navigate to /admin/structure/block.
  5. Enable the "Exposed form: advanced_forum_search-page" block, and show it for example in the "Content" area and only for "Forum topic" nodes. You can change this to your liking of course.

Users now can use this form from single forum nodes, and submitting it will take them to the search page.


If you want to make this available in your templates and position it within other elements, you'll have to edit the template.php of your theme add a hook_preprocess_X() implementation.

Choice depends on the template you want to add the form to. For example:

  • hook_preprocess_node() - to make the form available in node.tpl.php
  • hook_preprocess_page() - to make the form available in page.tpl.php
  • hook_preprocess_html() - to make the form available in html.tpl.php

Here's the code:

function YOUR_THEME_preprocess_REPLACE_THIS(&$variables) {
  // Load the view and generate the search form.
  // You can have any dynamic conditions here (e.g. limit to some content types
  // and so on).
  $view = views_get_view('advanced_forum_search');
  $form_state = array(
    'view' => $view,
    'display' => $view->display_handler->display,
    'exposed_form_plugin' => $view->display_handler->get_plugin('exposed_form'),
    'method' => 'get',
    'rerender' => TRUE,
    'no_redirect' => TRUE,
  $variables['search_form'] = drupal_build_form('views_exposed_form', $form_state);

Then in your .tpl.php file you would use this code to display the form:

<?php print render($search_form); ?>

Note that this way the visibility settings in admin won't be applied.

  • Hmmm...this is working...
    – CodeNext
    Mar 30, 2016 at 20:24
  • Is there any way that search form can be placed besides the "New Topic" as shown in the image above? I understood that, this process is displaying the the search form view as a block and that block we are placing to the main-content. This way it can be placed either to the top or bottom of main page.
    – CodeNext
    Mar 30, 2016 at 21:17
  • That depends on your CSS. You could also make it available through a hook_preprocess_whatever() function, and then invoke it in the template. Will update my answer shortly. Mar 31, 2016 at 5:49
  • Answer updated. Mar 31, 2016 at 6:15
  • Well...I did not get few things, If you please can put light on that. I am little familiar with preprocess. Why you want to implement in page() or node() or html() tpl file. why not to the .tpl.php file where the the code of New topic is there. Why not in advanced-forum.naked.topic-list-outer-view.tpl.php which has the code of <?php if ($node_create_list): ?><div class="forum-node-create-links forum-node-create-links-top"><?php print $node_create_list ?></div> <?php endif; ?> which prints New topic. And put that tpl file in theme's templates folder.
    – CodeNext
    Mar 31, 2016 at 15:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.