A Simple Search Bar

  • I’ve made a page with a repeating block of member information. e.g., Name, City, Field of Interest, etc. I would like to make it searchable to visitors. I’m having a hard time working out the details from the Perch Docs to get a result. So far, every attempt has provided nothing visible. So I feel somehow there are steps I have missed or are assumed in the Docs. Is there anything that can help a beginner more practically?

  • drewm

    Approved the thread.
  • Yes Drewm, I did look at the included search page example. It did not work and it did not teach me anything that I could get to work.


    I also looked at the documentation, code examples, etcetera, and could not find anything that worked or explained how to make it work. This is the last place I have looked for help with this.


    Here is a page showing all the information that I want users to to search:
    http://afcc-nj.org/members.php


    The red search bar currently there is:
    <?php perch_search_form(); ?>

    https://docs.grabaperch.com/fu…search/perch-search-form/


    Is there anything that can help me figure this out?

  • You know, I did that before too. It is installed now on my page and produces no visible thing.

    http://afcc-nj.org/members.php


    My understanding is that function searches web content, not the data content. Is that what I really need?


    Also, my frustration with the reference pages is they don’t really explain anything. There is no Rosetta stone to help grasp the meaning, no real example of what is basic use. Yes, there is some code and the options array, but using that code example with a page in my templates/search PRODUCES A BIG NOTHING, RENDERS AS NOTHING, BLANK BLANK BLANK.


    I’m sure the solution is simple and reasonable for an experienced person, please help me get there.

  • Did you remove the search form?


    A functioning search configuration will typically render a search form:


    perch_search_form();


    and also render the results of a search:


    perch_content_search(perch_get('q'));


    Shouting at me isn't going to help get your page working. What _will_ help is if you show us the code you're using and describe what happens when you try to search. Then we can follow logical steps to diagnose what needs to change to get it working.

  • This is the code I used, ad suggested…

    PHP
    1. <?php
    2. $query = perch_get('q');
    3. perch_content_search($query, array(
    4. 'count'=>5,
    5. 'excerpt-chars'=>300,
    6. 'template'=>'search-form.html'
    7. ));
    8. ?>

    Here is the same Perch supplied search form that was called perviously with <?php perch_search_form(); ?>

    Code
    1. <perch:form id="search" method="get">
    2. <div style="padding: 10px; background: gainsboro;">
    3. <perch:label for="q">Search</perch:label>
    4. <perch:input type="search" id="q" />
    5. <perch:input type="submit" value="Go" />
    6. </div>
    7. </perch:form>

    When using <?php perch_search_form(); ?> the form appears. When the actual form is listed as as a template option in perch_content_search()then nothing appears. No code at all. When the template option is removed, then the heading “Search” is written, and nothing else at all.

  • Sorry for the “shouting” (I call it emphasis, don’t take it personal)


    As you can see now, I combined those two functions (which I never read in the docs or references… it must be something you have to just know. See? Now we are going somewhere. I will fiddle with this for awhile and hope that your kindness will still be available if I dig myself into another hole. Thanks Drewm.