Is there a way I can have my search form in nav bar not collapsed when screen size decreases? I'm using bootstrap on Drupal 7

  • How do you render your search form? Is it a block assigned into a region? – Madelyn Cruz Jul 25 '17 at 2:41
  • If I understood you, I have a search form block in the navigation section and it's set in line with the main menu – axelmukwena Jul 25 '17 at 10:08
  • I see. Do you have page.tpl.php in your theme folder? – Madelyn Cruz Jul 25 '17 at 10:12
  • yes, and it's located at 'sites/all/themes/bootstrap_subtheme/templates/page.tpl.php' – axelmukwena Jul 25 '17 at 10:22

You can change your markup using the page.tpl.php

  • Copy the page.tpl.php file from /bootstrap/templates/system to your theme.
  • Edit the page.tpl.php that you've copied.
  • Move the line 108 - 110 below / above the navbar-collapse collapse div.

enter image description here

  • Create a new div.
  • Put the code from line 108 - 110 into the new div.
  • Save
  • The changes should be like the screenshot below.

enter image description here

  • Flush cache
  • It worked, but the function disabled the collapse of both the main menu and search form. What I wanted was to disable the search form from collapsing, but the rest i.e main menu should collapse. Is that possible? – axelmukwena Jul 25 '17 at 10:55
  • I suspect that you have a multiple blocks assigned in navigation region. You might want to consider to create a new region. Edit your theme .info file. At the regions area starting from line 11, create a new region there eg. regions[navigation_right] = 'Navigation Right' Save. Move back the $page['navigation'] into its original placement. Render your new region Eg. $page['navigation_right']. Save. Flush cache. Move your search block into 'navigation_right' region. – Madelyn Cruz Jul 25 '17 at 11:03
  • Or you can check this link to see the samples on how to create new block region. drupal.org/node/1088718#comment-4194802 – Madelyn Cruz Jul 25 '17 at 11:05
  • Thank a lot @Madelyn, adding a new region worked perfectly and it'll be useful with a lot more I've been struggling with. – axelmukwena Jul 25 '17 at 11:49
  • My pleasure. Good to hear that it suits to your requirements. – Madelyn Cruz Jul 25 '17 at 12:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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