Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

How to add a search field?

edited June 2012 in Vanilla 2.0 - 2.8

Hi all,

I can't find any documentation about how to add a search field to the forums -- other than to add a community plugin.

The closest thing I can find is a document about how MySQL does searching -- http://vanillaforums.org/docs/search -- but that document doesn't say exactly how to add the search field.

Help?

Tagged:

Best Answers

  • peregrineperegrine MVP
    edited June 2012 Answer ✓

    the problem if you are using the embedfriendly theme and you choose hide sidepanels you won't see the search box. So you will need to manipulate things if you want it to show up and you have hidden side panel. you will need to look at what hide the panels. you might be able to remove the panel class from just the search box of look at the javascript (if any) or the css to get search panel but not other panels.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • peregrineperegrine MVP
    Answer ✓

    panels are hidden in embedfriendly theme via the singlecolumn.css

    If you still want singlecolumn

    you could just add

    {searchbox} in default.master.tpl in front of the dashboard link or after signout and style accordingly in singlecolumn.css. Just don't put the id="Panel" attached to any element if you want it visible.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

Answers

  • 422422 Developer MVP

    vanilla has a built in search field

    There was an error rendering this rich post.

  • 422 said:
    vanilla has a built in search field

    Thank you 422. How do I implement it? I'd like to place it at the top of the categories page. There's no documentation I've been able to find as of yet.

  • if you use default.master.tpl
    
     <div class="SearchBox">{searchbox}</div>
                 {asset name="Panel"}
              </div>
    
    
    or something like this
    
     $Form = Gdn::Factory('Form');
       $Form->InputPrefix = '';
       $Result =
          $Form->Open(array('action' => Url('/search'), 'method' => 'get')).
          $Form->TextBox('Search', array('placeholder' => T('Search'))).
          $Form->Button('Go', array('Name' => '')).
          $Form->Close();
    

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Thanks @peregrine -- will try that later today or tomorrow and report back the results.

  • vanilla/library/vendors/SmartyPlugin is a wealth of information and it is very easy to create your own. I'm surprised this has never been mentioned.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • edited June 2012

    peregrine said:
    if you use default.master.tpl

    `<div class="SearchBox">{searchbox}</div>`
    

    {asset name="Panel"}
    </div>

    Hi @peregrine -- sure enough, the default.master.tpl in EmbedFriendly (which I'm using) already had that section you listed. Is it that I need to enable the search box? If so, how do I do that?

  • @peregrine -- how did you drop in that grey/white alternating bar code display in your post above?

  • 422422 Developer MVP

    @philag i dont get why you want to add this when it is already added, are you using a custom theme?

    There was an error rendering this rich post.

  • peregrineperegrine MVP
    edited June 2012

    philAG said:

    peregrine said:
    if you use default.master.tpl

    <div class="SearchBox">{searchbox}</div>
    {asset name="Panel"}
    </div>

    Hi @peregrine -- sure enough, the default.master.tpl in EmbedFriendly (which I'm using) already had that section you listed. Is it that I need to enable the search box? If so, how do I do that?

    Depending on the theme you are using, it will have a default.master.tpl or a default.master.php. If you have the EmbedFriendly them the Search box should show up because it looks at the default.master.tpl file.

    I haven't looked into where the tpl's are called from. But if your theme has a tpl - you can just add the above if it doesn't already have it. If you are using php, the other code line 10-16 in the post above may work.

    philAG said:
    @peregrine -- how did you drop in that grey/white alternating bar code display in your post above?>

    cut and paste your code. then select (hilight it with you mouse) then press the C in the buttonbar.

    the bold markdown is hit or miss so the bold html tags work better. The code and pre tags aren't the greatest within this context.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • peregrineperegrine MVP
    edited June 2012 Answer ✓

    the problem if you are using the embedfriendly theme and you choose hide sidepanels you won't see the search box. So you will need to manipulate things if you want it to show up and you have hidden side panel. you will need to look at what hide the panels. you might be able to remove the panel class from just the search box of look at the javascript (if any) or the css to get search panel but not other panels.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • peregrineperegrine MVP
    Answer ✓

    panels are hidden in embedfriendly theme via the singlecolumn.css

    If you still want singlecolumn

    you could just add

    {searchbox} in default.master.tpl in front of the dashboard link or after signout and style accordingly in singlecolumn.css. Just don't put the id="Panel" attached to any element if you want it visible.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • peregrine said:
    the problem if you are using the embedfriendly theme and you choose hide sidepanels you won't see the search box. So you will need to manipulate things if you want it to show up and you have hidden side panel. you will need to look at what hide the panels. you might be able to remove the panel class from just the search box of look at the javascript (if any) or the css to get search panel but not other panels.

    So that's why -- that fixed it :)

    peregrine said:

    philAG said:
    @peregrine -- how did you drop in that grey/white alternating bar code display in your post above?>

    cut and paste your code. then select (hilight it with you mouse) then press the C in the buttonbar.

    See I did that, and then it started interpreting the <div class="SearchBox"> instead of just showing the characters. Even when I do tinker with the spaces a bit -- did I mention I prefer Texile to Markdown -- I don't get the alternating grey/white bars with the line numbers like you did in this comment -- http://vanillaforums.org/discussion/comment/162439/#Comment_162439 -- it's just a single white-background block:

    <div class="SearchBox">{searchbox}</div>
    {asset name="Panel"}
    </div>
    
  • Weird -- now it gives me the alternating grey/white background with the line numbers.

  • @422 said:
    @philag i dont get why you want to add this when it is already added, are you using a custom theme?

    Nope, EmbedFriendly. @peregrine figured it out: the single-columnar config for EmbedFriendly hides the search field because that search field is part of the aside-column.

  • 422422 Developer MVP

    Well i never knew that.

    There was an error rendering this rich post.

  • 422 said:
    Well i never knew that.

    @422 sounds like an opportunity for ya - single column with search box that embeds well for the people who don't want to mess with css. But the search will only be there as a token because it can't find much on anything anyway :).

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • 422422 Developer MVP
    edited June 2012

    I dont touch embed themes mate, i have enough on my plate lol.

    There was an error rendering this rich post.

  • yep they are a nightmare.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

Sign In or Register to comment.