Problems, need help? Have a tip or advice? Post it here.
10 posts Page 1 of 1
I am using the search tag on a page to pull up a list of search results. No matter what I search for it shows up empty. Below is my code:

Search Form:
Code: Select all
<cms:form id="search-form" method="get" action="<cms:link 'career-search.php' />" anchor='0' keywords="<cms:gpc 's' />">
                        <div class="cute-4-tablet">
                           <input type="text" name="s" placeholder="SEARCH CAREERS" />
                           <input type="submit" class="button-2" value="SEARCH"/>
                        </div>
                     </cms:form>


Search Results Page:
Code: Select all
<cms:search masterpage='positions.php'>
                        <cms:set results='yes' scope='global' />
                        <article class="post">
                           <div class="post-img cute-4-tablet">
                              <iframe src="<cms:show loc_map />" width="100%" height="265" frameborder="0" style="border:0"></iframe>
                           </div>
                           <div class="cute-8-tablet">

                              <h1 class="post-car"> <cms:show pos_title /></h1>
                              <div class="post-meta">
                                 <p class="date"><i class="fa fa-calendar"></i><cms:date k_page_date format='F d, Y' /> </p><p class="name"><i class="fa fa-map-marker"></i> <a href="#"><cms:show pos_address /></a> </p>
                              </div>
                              <p class="text-car">
                                 <cms:show pos_desc />
                              </p>
                              <a href="<cms:show app />" target="_blank" class="btn-default" ><cms:show btn_text /></a>

                           </div>
                        </article>
                        <div class="cute-12-tablet"><hr></div>
                        <cms:no_results>
                           <h3>No careers found for "<cms:show k_search_query />"</h3>
                        </cms:no_results>
                     </cms:search>
Hi,

The keywords="<cms:gpc 's' />" needs to be used with cms:search tag (and not the form as in your code).

Please modify the code to make it
Code: Select all
<cms:search masterpage='positions.php' keywords="<cms:gpc 's' />">
..

If it still does not work, test it by hard-coding a keyword that you are sure is present (at least 4 characters in length) e.g.
Code: Select all
<cms:search masterpage='positions.php' keywords="abracadabra">
..

If this works (as it really should), try to see why the 's' variable is not getting passed via querystring.

Hope it helps.
The form is gone now. Below is the updated code:
Code: Select all
<cms:search masterpage='positions.php' keywords="<cms:gpc 's' />">
                        <cms:form id="search-form" method="get" action="<cms:link 'career-search.php' />" anchor='0'>
                           <div class="cute-4-tablet">
                              <input type="text" name="s" placeholder="SEARCH CAREERS" />
                              <input type="submit" class="button-2" value="SEARCH"/>
                           </div>
                        </cms:form>
                     </cms:search>
Jon, why are you nesting the form within the cms:search block?

The two are distinct entities and should be kept separate.
The form, for example, could be on the home-page and the cms:search block in the 'career-search.php' template the form is leading to. It can also be on the 'career-search.php' template (say, somewhere on the top) but has to be outside the cms:search block -
Code: Select all
<cms:form id="search-form" method="get" action="<cms:link 'career-search.php' />" anchor='0'>
    <div class="cute-4-tablet">
        <input type="text" name="s" placeholder="SEARCH CAREERS" />
        <input type="submit" class="button-2" value="SEARCH"/>
    </div>
</cms:form>

<cms:search masterpage='positions.php' keywords="<cms:gpc 's' />">
    .. display search results ..
</cms:search>
Facepalm. I moved it to where it should be and still not getting any results. I am trying to search keywords that match the position title.
Have you tried testing by using a hard-coded word that you know is in there e.g. as follows ?
Code: Select all
<cms:search masterpage='positions.php' keywords="abracadabra">
Yea still getting the no results found snippet.
That is strange.
Can you please PM me the FTP + phpMyAdmin + Couch creds?
I'll need to take a look at the database.
Hey KK. Any idea what could be going on here?
I had a look at your setup and found that the problem was this -
the 'positions.php' template that was being searched was declared as follows
<cms:template title='Positions' clonable='1' executable='0' order='8'>

Since this template is non-executable, the search tag ignored its pages.

I modified the definition to
<cms:template title='Positions' clonable='1' executable='1' order='8'>

Refreshed the template as super-admin for the changes to persist and now the search results show up as expected.
10 posts Page 1 of 1