List Filter not returning correct results

0

Here's my 'members' pod setup:

name (txt) * last_name (txt) * family_courtesy (txt) * address1 (txt) * address2 (txt) city_state_zip (txt) * phonenumber (txt) * zone (num) children (txt)

Here's the code for my WordPress template page for displaying Members:

<pre>

<?php /* Template Name: Member Directory */

get_header(); ?>

<div id="middle_wrapper"> <div id="middle" class="outerBorder"> <div class="leftColumn"> <?php include(TEMPLATEPATH."/sidebar_left.php");?> </div>

    <div style="clear:right;"></div>

    <div class="middleColumn" style="width: 700px; float: left; padding: 0px 10px;">      
        <div id="pageContent">
            <h1 class="mainHeading"><?php the_title(); ?></h1>                     
                <?php
                    // Bypass the List Template
                    $Record = new Pod('members');
                    $Record->findRecords('last_name asc', 25);
                    $i = 0;
                ?>

            <?php 
                //check if user is logged in
                if (is_user_logged_in()) { 
            ?>

                <div style="float:left;"><?php echo $Record->getFilters('last_name, name', 'Search Members'); ?></div>
                <div style="float:right;"><?php echo $Record->getPagination(); ?></div>
                <div style="clear:both;"><br/></div>                    
                <?php
                    while ($Record->fetchRecord())
                    {
                        ?>
                        <?php 
                            $zone = $Record->get_field('zone');
                            if ($zone != "")
                                $zone = number_format($zone, 0);
                        ?>
                        <div id="memberRow">
                            <div id="memberDescription">
                                <h2 class="homeTitle"><?php echo $Record->get_field('last_name'); ?>, <?php echo $Record->get_field('name'); ?></h2>
                                <p>
                                    <strong>Address:</strong> <?php echo $Record->get_field('address1');?> <?php echo $Record->get_field('address2');?> <?php echo $Record->get_field('city_state_zip');?><br/>
                                    <strong>Phone:</strong> <?php echo $Record->get_field('phonenumber');?><br/>
                                    <?php
                                        if ($zone != "") {
                                    ?>
                                    <strong>Zone:</strong> <?php echo $zone;?><br/>
                                    <?php
                                        }
                                    ?>
                                    <?php 
                                        $children = $Record->get_field('children');
                                        if ($children != "") {
                                    ?>
                                        <strong>Children:</strong> <?php echo $children; ?><br/>
                                    <?php } ?>
                                </p>
                            </div>
                            <div style="clear:both;"></div>
                        </div>
                <?php
                    $i++;
                    }
                ?>

                <p style="float:right;"><?php echo $Record->getPagination(); ?></p>

            <?php
                } else {
            ?>
                <p>This area is for Members only.  If you are a member of Old Hickory, you may <a href="http://oldhickory.server293.com/wp-login.php?redirect_to=/members/member-directory/"<strong>login</strong></a> or <a href="/contact/request-access/"><strong>request access</strong></a>.</p>
            <?php } ?>
        </div>
    </div>
</div>

</div>

<?php get_footer(); ?>

</pre>

I'm trying to enable searching on a member's last_name or name, but the filter will only work for the first few letters. For example, if I enter 'g' I see a record that has 'Gaines' for the last_name. But, if I enter 'gain' I don't see 'Gaines' in the result anymore.

Any idea of what I'm doing wrong?

asked Sep 18 '09 at 9:51

ckpicker

20

add comment
enter at least 15 characters

4 Answers

0

@caseypicker - I believe that the List Filter text search only works on a pod's name field. Try entering-in the first few letters of mr/mrs Gaines' first name (I'm assuming it has a 'g' in it) and see if they don't still come up.

answered Sep 17 '09 at 4:08

creativenadir

1

add comment
enter at least 15 characters
0

I think you're right. Is there any way to include additional fields in the text search?

answered Sep 18 '09 at 12:25

ckpicker

20

add comment
enter at least 15 characters
0

@cpicker - Not yet. If you look in the findRecords() function, you'll see its implementation. It's pretty basic. We'll undoubtedly be adding an option to select the searchable columns for each pod.

But it'll be after a couple other important features are added (multiple public forms per page, file manager, security updates).

answered Sep 18 '09 at 8:23

logikal16

249

add comment
enter at least 15 characters
0

Nice! I was able to modify that function since I'm only using filtering on one pod page. I just added that specific field to the SQL query:

Pod.class.php line 419:

<pre> $search = "AND ((t.name LIKE '%$val%') or (t.last_name LIKE '%$val%'))"; </pre>

answered Sep 18 '09 at 9:51

ckpicker

20

add comment
enter at least 15 characters