by
KK » Tue Jun 26, 2012 8:38 pm
Hi Matt and welcome
I am sorry you found the search documentation not helpful enough but don't worry I'll be happy to fill in the perceived gaps.
..they don't address how to display the information returned after querying.
OK, I assume you understood the relation between the 'search_form' and the 'search' tag -
the 'search_form' simply sets the keywords searched for in the querystring and the 'search' tag picks them up from there.
The 'search' tag goes through the database looking for matching pages and, for our example, suppose 3 pages are found. The following snippet then iterates through each of the 3 pages and sets ALL the variables (the same that you'd expect to find had the pages been fetched using cms:pages tag) for each of the page -
- Code: Select all
<cms:search>
<!-- All the variables of the pages found will be available here -->
</cms:search>
Try putting cms:dump tag to see what I mean
- Code: Select all
<cms:search>
<!-- All the variables of the pages found will be available here -->
<cms:dump />
</cms:search>
In addition to the regular variables, the search tag also sets two extra variables
k_search_title and k_search_excerpt.
These two variables have the search terms highlighted. The k_search_excerpt additionally also brings together excerpts of the various places in the page that the search terms were found (a term, for example, could be found at the top of the page and the second time at the bottom - k_search_excerpt outputs both the lines).
Is there any sort of "k_is_search" variable to check?
Such a variable is not needed. If the querystring contains the search terms, the 'search' tag will display the result else not.
Is there any way to sort search results in descending order? I tried order="desc" but to no avail.
The search tag actually uses an algorithm where it ranks the pages according to their relevance with the terms being searched (e.g. how many times the term appears in a page, where does the term appear etc.) and then sorts the pages with the most important listed first. This, IMHO, makes the most sense for search results. No other form of display is supported.
Can I change the length of text output by "k_search_excerpt"?
I suppose you can try using cms:excerptHTML tag (
http://www.couchcms.com/docs/tags-refer ... thtml.html). But please remember you could end up cutting off the highlighted search terms. the decision is yours.
Hope this answers your questions. Please feel free to post in if you still have any confusions on this topic.
Thanks