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

I try to get on my search result page a drill down function.
I use as search <cms:search_form msg='Enter keywords' processor="<cms:show k_site_link/>search.php"/> once the visitor is on the result page I'm trying to pass a drill down function with some buttons and a variable called searchfilter ( <cms:set searchfilter=''/>) then pass it to the <cms:search masterpage='variable result' > see:

Image

or search page live.

Somehow my attempts on this aren't working is this possible or do I try to do something that can't be done this way ?

Thanks
I load frameworks and write bugs on top of them, after that I rearrange the code so that it looks like a cool product.
Hi,

It is certainly doable.

Not sure what method you are using to pass the selected parameter to the search tag. Is is via querystring, cookie or something else?

Please post in the full source code of your template and it is only then that we'd be able to know what might be going wrong.

Thanks.
hi KK,

I was trying to set a variable by a click of a button, something like onClick function.

<cms:set searchfilter='' 'global'/>

<cms:form action='' method="POST">

<div class="button-bar">

<div class="button-group">

<li><a href="#" class="tiny button">Filter this list by :</a></li>
<a href="" <cms:input class="tiny secondary button" type="submit" name="news" value="news.php"/>News</a>
<a href="" <cms:input class="tiny secondary button" type="submit" name="products" value="products.php"/>Products</a>
<a href="" <cms:input class="tiny secondary button" type="submit" name="submit" value=""/> Show All</a>

<cms:if k_success_news >
<cms:set searchfilter='news.php'/>
</cms:if>

<cms:if k_success_products >
<cms:set searchfilter='catalog.php'/>
</cms:if>


</div>

</div>
</cms:form>


<cms:show searchfilter/>

Also looked at a php option like :

<cms:php>$filter = $_POST['variable'];

<form method="POST" action="">
<input type="submit" name="variable" value="News.php" />
<input type="submit" name="variable" value="catalog.php" />
</form>

</cms:php>

But got a couch tag error on this one.
I load frameworks and write bugs on top of them, after that I rearrange the code so that it looks like a cool product.
Hi,

Couch's cms:form tag does not support multiple submit buttons. However, as usual, we can use a bit of PHP to tide over that.

Here is your modified code that is setting the variables properly.
Code: Select all
<cms:set searchfilter='' 'global'/>

<cms:form action='' method="post" anchor='0'>
    <cms:if k_success>
        <cms:php>
            global $CTX;
            if( isset($_POST['news']) ){
                $CTX->set( 'searchfilter', 'news.php', 'global' );
            }
            elseif( isset($_POST['products']) ){
                $CTX->set( 'searchfilter', 'catalog.php', 'global' );
            }
        </cms:php>
    </cms:if>
   
    <div class="button-bar">

        <div class="button-group">

        <li><a href="#" class="tiny button">Filter this list by :</a></li>
        <input class="tiny secondary button" type="submit" name="news" value="News"/>
        <input class="tiny secondary button" type="submit" name="products" value="Products"/>
        <input class="tiny secondary button" type="submit" name="submit" value="All"/>

        <cms:input type='hidden' name='dummy' />

        </div>

    </div>
</cms:form>

Searchfilter: <cms:show searchfilter />

Please try it out and let me know if this helps.

Thanks.
Thanks thanks thanks...

This works very well !

I had to adjust the page where the snippet has to load .... <cms:search masterpage='<cms:show searchfilter />' limit='10'> must be... <cms:search masterpage="<cms:show searchfilter />" limit='10'> in this case ( "" instead of '').

I suppose the global $CTX; does the trick !? what it means and does is for me still some abracadabra.

Many thanks again.
I load frameworks and write bugs on top of them, after that I rearrange the code so that it looks like a cool product.
You are welcome :)

The double-quotes is crucial for Couch to consider the enclosed contents as code it needs to execute.

The PHP is not too difficult. The following statement
Code: Select all
$CTX->set( 'searchfilter', 'news.php', 'global' );

is equivalent to the following Couch statement
Code: Select all
<cms:set searchfilter='news.php' 'global' />
6 posts Page 1 of 1