Admin Search Multiple Columns

2

I know that this feature was requested for Pods UI but has anyone been able to figure out how to search through other columns other than the 'name' column?

TIA.

asked May 25 '10 at 4:44

sdfurniture

21

add comment
enter at least 15 characters

5 Answers

2

Pod.class.php - line 486

 if (!empty($_GET['search']))
    {
        $val = pods_url_variable('search', 'get');
        $search = "AND (t.name LIKE '%$val%' OR t.anothercolumn LIKE '%$val%' OR t.anothercolumn LIKE '%$val%')";
    }

answered May 26 '10 at 7:31

jackson

33

edited May 26 '10 at 7:31

Very cool, thank you! Worked perfectly. Only thing, though, is that this doesn't seem to affect the search bar in the Browse Content section where all the entries for all the pods are listed. Any ideas why this is so? – modesto.mouse May 27 '10 at 12:18
add comment
enter at least 15 characters
1

You would have to use a custom WHERE clause to do this using the LIKE operative...

W3 Schools SQL LIKE Reference

If you require that the results be in some sort of relevance order do a google search on sql order by relevance. Make sure that you are looking @ mySQL topics too and not mssql ones. There are many resources out there on that matter. You might even need to write a custom query for that...

Good luck...

answered May 25 '10 at 5:33

chriscarvache

73

would you happen to know if there's a way to switch the column being searched from the 'name' column to something else? – sdfurniture May 25 '10 at 5:43
add comment
enter at least 15 characters
1

Not really an answer but more of a request for further clarification:

Can anybody tell me which file I would have to edit to make this happen? (by 'this' I mean forcing Pods to search additional columns and/or forcing Pods to search a different column other than the Name column).

answered May 26 '10 at 1:38

modesto.mouse

-19

add comment
enter at least 15 characters
1

@jackson THANK YOU

@ modesto.mouse i ran into that same issue with the 'Browse Content' page b/c i'm using multiple pods as well. I did some digging but ran into a wall. here is the code that seems to specify what the search bar in the 'Browse Content' page searches for (it's in core/manage_content.php):

if (!empty($dtname))
{
    $where[] = "t.name = '" . pods_sanitize($dtname) . "'";
}

if (!empty($_GET['keywords']))
{
    $where[] = "p.name LIKE '%" . pods_url_variable('keywords', 'get') . "%'";
}

i just need a way to allow admin(s) to search through multiple pods using a column other than or in addition to the name column. i see this happening in either the 'Browse Content' page (which is able to call all pods but searches only the name column), or in a custom Pods UI page that pulls all pods (if possible then jackson's solution will work here). only thing is i'm no ninja programmer so if anyone can lend a hand- it will be very much appreciated!

TIA.

answered May 27 '10 at 4:07

sdfurniture

21

edited May 27 '10 at 4:14

add comment
enter at least 15 characters
0

answered May 26 '10 at 9:24

Masino Sinaga

41

edited May 26 '10 at 9:25

add comment
enter at least 15 characters