All Low add-ons are now owned by EEHarbor. Read the blog post.

Support archive

Search entry_id and number

ngoncom 27 Apr 2016 05:07 question, complete

Hi Low!

I have one input for user type: keywords or number.

If user type number only I want Low Search understand will search entry_id.

I've tried but seem Low Search can't search number, it results all entries.

Thank Low!

Replies

  1. ngoncom 27 Apr 2016 06:43

    Hi,

    I find out a way to solve this:

    I using php regex to check keywords to know it is text or number, if it is number I show entry_id = number.

    I enable php (input) and using this code:

    {exp:low_search:results ... 

    <?php if (preg_match("/([0-9]+)/i", $_GET['keywords'])):?>
    entry_id="<?=$_GET['keywords']?>"
    <?php endif; ?>

    {/exp:low_search:results}

    Thank!

  2. Low 27 Apr 2016 10:08

    I guess that's one way of doing it. Slightly safer would be to create an extension that sets the keywords="" or entry_id="" parameter based on the same principle.