Forum for discussing general topics related to Couch.
3 posts Page 1 of 1
I have a search page. It works with keywords. Let's say I searched for 'keyword' it lists me the pages that includes 'keyword'

What I want is:

I want to list all of the pages if I do not write any keywords on search page.

How can I make this?
I want to list all of the pages if I do not write any keywords on search page.

I think you can use <cms:gpc> to ascertain if a keyword has been provided - if yes, use <cms:search> to show the results; if no, use <cms:pages> to list all the pages.
Expanding @KK's perfect advice here - code from the docs (http://docs.couchcms.com/concepts/using-search.html) can be wrapped in a coditional, and if keyword is empty, then use regular cms:pages, otherwise use cms:search with keyword.
Code: Select all
<cms:set my_keywords = "<cms:gpc 's' />" scope='global'/>
<cms:if "<cms:strlen my_keywords />" >
    <cms:search masterpage='blog.php' limit='10' keywords=my_keywords >
    [...]
<cms:else />
    <cms:pages masterpage='blog.php' limit='10' >
    [...]
</cms:if>
3 posts Page 1 of 1