Problems, need help? Have a tip or advice? Post it here.
4 posts Page 1 of 1
Hi,

Apologies if this is a stupid question or if this has been answered before!

I've set up a search facility for my News archive section of my site. With each news article there is an image. The search results show the image file name at the beginning of search excerpt in the result, which I don't want -- I just want the text. I've tried using ignore as below but his does not work. Any ideas?

<cms:show k_search_excerpt ignore='img' />

Also is 'k_search_query' the query that is entered into the search box?

Because I've tried this on my search page and it doesn't work:

<p>You searched for <span><cms:show k_search_query /></span></p>
Hi and welcome to our forums.

There are two part to your questions. I'll try and answer each in turn.

1. The search results show the image file name ..
To be truthful, it was probably a mistake on our part to include values of editable regions like 'file', 'image' etc. in the textual search results.

We have made some changes now so that the search result will show only values from regions of type 'text'. 'textarea' and 'richtext'.
These changes will make their way into the next release of Couch.

For now, I am attaching a patch for the current version 1.1.1.
page.zip
(42.92 KiB) Downloaded 592 times

Please overwrite the existing 'page.php' within your Couch installation with the one attached (after backing up the older file).

For the changes to show up in your existing pages, please re-save all your existing pages after making some dummy changes to any of the data (e.g. add a space after some text in any editable region).
This will cause the modified code to recalculate the search text.

2. .. is 'k_search_query' the query that is entered into the search box?
Yes it is. It is a space separated string containing all the words entered into the search box.

However, there is a catch in using it that must have stumped you.
This variable is set by the <cms:search tag and hence becomes available in your page only after the 'search' tag (or within the 'search' tag).
You probably must be using it before the 'search' tag.

Following is a sample snippet that you can modify to use this variable -
Code: Select all
<cms:search masterpage='news.php' limit='15' keywords="<cms:gpc 's' />">
   <cms:if k_paginated_top >
      <cms:set my_records_found='1' scope='global'/>
      <h2>Results</h2>
      <p class="search">
         <cms:show k_total_records /> results for <strong><cms:show k_search_query /></strong>
         (displaying: <cms:show k_record_from />-<cms:show k_record_to />)
      </p>
   </cms:if>

   <h3 class="search"><a href="<cms:show k_page_link/>"><cms:show k_search_title /></a></h3>
   <p class="search"><cms:show k_search_excerpt /></p>

   <cms:if k_paginated_bottom && k_paginator_required >
      <cms:paginator />
      <p class="search">Page <cms:show k_current_page /> of <cms:show k_total_pages /></p>
   </cms:if>
</cms:search>

<cms:if my_records_found!='1' && "<cms:gpc 's' />">
   <h2>Sorry, no results found</h2>
   <p>
      You searched for <strong><cms:show k_search_query /></strong>
   </p>
</cms:if>

Hope this helps.
Do let us know.
Brilliant! Thanks for your quick response -- both these fixes worked perfectly!

PS. I'm really really impressed by this product, and I hope that it continues to grow in popularity so that development continues. I'm certainly going to be using it plenty!
I am glad it helped and thank you very much indeed for your kind words :)
4 posts Page 1 of 1
cron