Forum for discussing general topics related to Couch.
8 posts Page 1 of 1
Hey all,

I'm new to CouchCMS and CMSes in general. I love CouchCMS so far as I've started to integrate it into a work website.

The function I need help with is the search_form tag.

I have my search form on my home page (index.php) which will be migrated later on to other pages throughout the site. I additionally have a search.php which I want to display results of said searches.

I'm using this code on the index page (where the search originates from):
Code: Select all
<cms:search_form msg='Search the database!' processor="<cms:show k_site_link/>search.php"/>
            <cms:search limit='10'>
            <cms:if k_paginated_top >
               <div>
               <cms:if k_paginator_required >
                  Page <cms:show k_current_page /> of <cms:show k_total_pages /><br>
               </cms:if>
               <cms:show k_total_records /> Pages Found -
               displaying: <cms:show k_record_from />-<cms:show k_record_to />
               </div>
               </cms:if>
         <h3><a href="<cms:show k_page_link/>"><cms:show k_search_title /></a></h3>
         <cms:show k_search_excerpt />
         <hr>
         <cms:paginator />
         </cms:search>
.

If I remove the processor, I get the results of my search inline. When I put the processor, it does route me to the search.php page but with no results. I understand that a search tag snippet needs to go into the search.php page but I cannot get it to work, I was wondering if someone could help me out.

Thanks!
Hello and welcome :)

Your code needs to be split up in two parts -
1. The form should be in index.php
Code: Select all
<cms:search_form msg='Search the database!' processor="<cms:show k_site_link/>search.php"/>

2. The code that lists the found pages should be in search.php
Code: Select all
            
<cms:search limit='10'>
    <cms:if k_paginated_top >
        <div>
            <cms:if k_paginator_required >
              Page <cms:show k_current_page /> of <cms:show k_total_pages /><br>
            </cms:if>
            <cms:show k_total_records /> Pages Found -
            displaying: <cms:show k_record_from />-<cms:show k_record_to />
        </div>
    </cms:if>
    <h3><a href="<cms:show k_page_link/>"><cms:show k_search_title /></a></h3>
    <cms:show k_search_excerpt />
    <hr>
    <cms:paginator />
</cms:search>
         

From what I could gather from your post, you have already tried putting in the listing code in search.php
it does route me to the search.php page but with no results
It should work since, as you stated, it worked inline on index.php.
Perhaps search.php is not registered as a Couch template? Can you see it in admin sidebar?

Try searching for the same term that fetched result on index.php.
Awesome! That worked perfectly! Thank you so much.

Is there a way to code in a message for when no results are returned such as "Nothing matched your query"?

Thank you for the quick response!
Try putting in a cms:no_results block in there
Code: Select all
            
<cms:search limit='10'>
    ...
    ...   
   
    <cms:no_results>
      <h3>No matching pages found</h3>
    </cms:no_results>
   
</cms:search>

Hope this helps.
That worked like a charm. Thank you so much KK! :D

Lastly, if I wanted to theme the default search_form (try to match the aesthetics of the website), is this done through Couch or through my website's CSS?

(sorry for the question spam :oops: )
You are free to use your own styles.
You can create your own search form also.
The only thing Couch expects from the form is the textbox being named 's' (please do a view-source to see what the form generated by cms:search_form looks like).
Thank you for all the help KK
You are welcome :)
8 posts Page 1 of 1
cron