ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

How to change search parameters

January 30, 2011 3:05pm

Subscribe [2]
  • #1 / Jan 30, 2011 3:05pm

    NGiannini

    11 posts

    My website features both articles and references to different code elements for my students. For instance, I have individual pages for the

    <h1>
    tag and the

    tag. However, when I use the search functionality to search for something like <h1> I receive an error stating that the entry must be at least 3 characters long. Is there away of modifying the parameters to accept the < and > characters or to shorten the required search length?

    My code as of right now is only as follows:

    {exp:search:simple_form channel="news|pages" search_in="everywhere" no_result_page="search/no_results"}

    Thanks for any input or suggestions

  • #2 / Jan 31, 2011 2:56pm

    Barry Cogan

    291 posts

    HI NGiannini,

    There is nothing that can be done officially.

    What I am about to suggest is not recommended as it involves modifying expression engine files and will need to be re applied with any future updates.

    You can edit the system/expressionengine/modules/search/mod.search.php file.

    Lines 28-36 should look like this:

    class Search {
    
        var    $min_length        = 3;            // Minimum length of search keywords
        var    $cache_expire    = 2;            // How many hours should we keep search caches?
        var    $keywords        = "";
        var    $text_format    = 'xhtml';        // Excerpt text formatting
        var    $html_format    = 'all';        // Excerpt html formatting
        var    $auto_links        = 'y';            // Excerpt auto-linking: y/n
        var    $allow_img_url    = 'n';            // Excerpt - allow images:  y/n
        var    $channel_array     = array();
        var    $cat_array      = array();
        var $fields            = array();
        var $num_rows        = 0;

    Code: system/expressionengine/modules/search/mod.search.php


    We are going to reduce the $min_length by one

    class Search {
    
        var    $min_length        = 2;            // Minimum length of search keywords. Default length: 3

    Save your changed mod.search.php and you should be good to go!

    Remember: any time you update Expression engine you will need to re-apply this change!

    When I get a moment I will look into allowing < and > for you as well.

    Best regards,
    Barry

  • #3 / Jan 31, 2011 3:13pm

    NGiannini

    11 posts

    Thanks Barry I’ll give it a shot! If worse comes to worse the full element names will be fine for them to use.

  • #4 / Jan 31, 2011 3:15pm

    Barry Cogan

    291 posts

    Let me know if it works out for you 😊

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases