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

I am trying to implemenet the search function, but I am not able to integrate it to my website.
I have tried the following:
1. Putting the following to my index.php webpage.
1.1
Code: Select all
<cms:form method="get" action="<cms:link 'search.php' />" anchor='0'>
<cms:input type="text" value="" name="s" />
<cms:input type="submit" value="Go" name='submit' />
</cms:form>

-------------------------------------------------------------
OR
Code: Select all
1.2 <cms:search_form msg='Enter keywords' processor="<cms:show k_site_link />search.php" />

-----------------------------------------------------------------
2. Putting the following to my search.php page:
Code: Select all
<?php require_once( 'couch/cms.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:no_results>
Search query <pre><p><cms:show k_search_query /></p></pre> produced 0 results.
</cms:no_results>
</cms:search>
<?php COUCH::invoke(); ?>

It simply doesn't find anything
--------------------------------------------
And one more question:
---------------------------------------------
Is there anyway I can integerate a more flexible search functionality (say autocomplete or a search with less than 4 characters):
I am using JQM for my website: It suggests using the following code for remote autocomplete:
Code: Select all
$( document ).on( "pagecreate", "#myPage", function() {
    $( "#autocomplete" ).on( "filterablebeforefilter", function ( e, data ) {
        var $ul = $( this ),
            $input = $( data.input ),
            value = $input.val(),
            html = "";
        $ul.html( "" );
        if ( value && value.length > 2 ) {
            $ul.html( "<li><div class='ui-loader'><span class='ui-icon ui-icon-loading'></span></div></li>" );
            $ul.listview( "refresh" );
            $.ajax({
                url: "http://gd.geobytes.com/AutoCompleteCity",
                dataType: "jsonp",
                crossDomain: true,
                data: {
                    q: $input.val()
                }
            })
            .then( function ( response ) {
                $.each( response, function ( i, val ) {
                    html += "<li>" + val + "</li>";
                });
                $ul.html( html );
                $ul.listview( "refresh" );
                $ul.trigger( "updatelayout");
            });
        }
    });
});

Is it possible getting data from the DB via ajax using the above code.

Answering ANY of the above questions would be greatly appreciated.

Best regards,
Art
Hi,

I can only attempt to answer the first part of the question -
your code looks just fine to me.

So, what exactly do you see when you press the search button?
Is search.php loaded? Do you see "Search query produced 0 results"?
Or nothing is displayed?
Hi KK,

Thank you so much for the quick response.

I have actually figured it out - I had made a stupid question and not written any html code aside the above code in search.php. The search results fetched but we're not visible, so how at added the necessary html attributes, namely doctype, head, body and all those things.

Now I'm wondering what alternatives I have for CMS: show k_search_excerpt.

Are there any other available fields? I'd like to show only certain parts of the found page content, namely the full paragraph where a keyword has been found, by ignoring headings, but with k_search_excerpt it shows all headings and spans.

So is it possible to fetch only data inside p tags?

This is my first ever website and first ever experience with CMS .

Thank you for providing that my Ch flexibility to the CMS.

Regards,
Art
3 posts Page 1 of 1