jemproject / JEM-Project

JEM - an Event Manager for Joomla
https://www.joomlaeventmanager.net
GNU General Public License v3.0
27 stars 39 forks source link

Filters #34

Closed neyworg closed 11 years ago

neyworg commented 11 years ago

filters for search for various views is limited. Query already grabs information so why not use it to $filter_type?

Example in modes/eventlist.php // ############### case 'category' : $where .= ' AND LOWER( c.catname ) LIKE '.$filter; break;

    if ($params->get('filter'))
    {
        $filter = JRequest::getString('category', '', 'request');

        if ($filter)
        {
            // clean filter variables
            $filter         = JString::strtolower($filter);
            $filter         = $this->_db->Quote( '%'.$this->_db->getEscaped( $filter, true ).'%', false );

            $where .= ' AND LOWER( c.catname ) LIKE '.$filter;
        }
    }       

See in action at: http://www.usyw.org/events?category=tournaments or http://www.usyw.org/events?category=tournaments&filter_type=state&filter=Iowa

Fields that can be done this way are State, Date, Category,... whatever else makes sense.

neyworg commented 11 years ago

Please standardize pull down filters between views.

filter

JKoelman commented 11 years ago

@neyworg , it will be done... did restrict myself to the eventslist but will add it to the to-do list...

// Just wondering if this should be done, because wehn having a venue the list will show the same place, state etc and i guess you don't have to select them.

neyworg commented 11 years ago

Imagine having thousands of events spread out in over thousands of venues? Filtering options actually become really important.

JKoelman commented 11 years ago

in that case it's indeed really important, but was wondering if it needed to have all the filtering options there with the same venue. So if a venue is selected is it then usefull to select at street, city as it's the same for the venue.

Clipboard04

neyworg commented 11 years ago

for Simplelist and Category Events for sure.. but since the code is easily cut/paste from view to view would it not be just easier to keep them identical? To make them all uniform and standard? Same look/feel no matter what page you go to?

JKoelman commented 11 years ago

:) you do have a point (it will be added)

JKoelman commented 11 years ago

and a little add: if you want to change it yourself you're welcome to do so, otherwise it will be done at the end of the week..

neyworg commented 11 years ago

I would, but odds you would have to come back after me and fix it. I lack!! So a sample of what I am talking about from models/eventlist.php

//###############

    if ($elsettings->filter)
    {
        $filter         = JRequest::getString('filter', '', 'request');
        $filter_type    = JRequest::getWord('filter_type', '', 'request');

        if ($filter)
        {
            // clean filter variables
            $filter         = JString::strtolower($filter);
            $filter         = $this->_db->Quote( '%'.$this->_db->getEscaped( $filter, true ).'%', false );
            $filter_type    = JString::strtolower($filter_type);

            switch ($filter_type)
            {
                case 'title' :
                    $where .= ' AND LOWER( a.title ) LIKE '.$filter;
                    break;

                case 'venue' :
                    $where .= ' AND LOWER( l.venue ) LIKE '.$filter;
                    break;

                case 'city' :
                    $where .= ' AND LOWER( l.city ) LIKE '.$filter;
                    break;

                case 'date' :
                    $where .= ' AND LOWER( a.dates ) LIKE '.$filter;
                    break;

                case 'type':
                    $where .= ' AND LOWER( c.catname ) LIKE '.$filter;
                    break;

                case 'state':
                    $where .= ' AND LOWER( l.state ) LIKE '.$filter;
                    break;    

            }
        }
    }
    if ($params->get('filter'))
    {
        $filter = JRequest::getString('date', '', 'request');

        if ($filter)
        {
            // clean filter variables
            $filter         = JString::strtolower($filter);
            $filter         = $this->_db->Quote( '%'.$this->_db->getEscaped( $filter, true ).'%', false );

            $where .= ' AND LOWER( a.dates ) LIKE '.$filter;
        }
    }       
    if ($params->get('filter'))
    {
        $filter = JRequest::getString('category', '', 'request');

        if ($filter)
        {
            // clean filter variables
            $filter         = JString::strtolower($filter);
            $filter         = $this->_db->Quote( '%'.$this->_db->getEscaped( $filter, true ).'%', false );

            $where .= ' AND LOWER( c.catname ) LIKE '.$filter;
        }
    }       
    if ($params->get('filter'))
    {
        $filter = JRequest::getString('state', '', 'request');

        if ($filter)
        {
            // clean filter variables
            $filter         = JString::strtolower($filter);
            $filter         = $this->_db->Quote( '%'.$this->_db->getEscaped( $filter, true ).'%', false );

            $where .= ' AND LOWER( l.state ) LIKE '.$filter;
        }
    }
    if ($params->get('filter'))
    {
        $filter = JRequest::getString('city', '', 'request');

        if ($filter)
        {
            // clean filter variables
            $filter         = JString::strtolower($filter);
            $filter         = $this->_db->Quote( '%'.$this->_db->getEscaped( $filter, true ).'%', false );

            $where .= ' AND LOWER( l.city ) LIKE '.$filter;
        }
    }
    return $where;

}
neyworg commented 11 years ago

The hope was to have a filter that we can drill with. &city=omaha&state=nebraska can even add &country=US

I know this does not accomplish that, but I lack the skills.

JKoelman commented 11 years ago

about the drill down, maybe it can be done like the way of the search view. -> when selecting continent the country box appears, a city can be choosen, etc...

neyworg commented 11 years ago

I do not understand what you mean by search view. But to give you a working example of above:

http://www.usyw.org/events?category=tournaments&city=Porterville&state=California http://www.usyw.org/events?state=California http://www.usyw.org/events?category=tournaments&state=California

JKoelman commented 11 years ago

ahh, thx for the links.

In the search view of JEM you can search for a title but also select an continent. When pressing that filter you wil get a selectlist for country, then city etc.. but it are new boxes that are appearing, perhaps the javascript & code for it can be used and it has to be done in some other way. so not sure at the moment.

clipboard02

neyworg commented 11 years ago

Yes, it will work.. and truth is if search code migrated to list views then search view is pointless. Also filter needs to be collapsible or hidden.

neyworg commented 11 years ago

This request has been effectively neutered by the way the new filtering is done making #48 even more critical to be fixed before 2.0 release.

JKoelman commented 11 years ago

@neyworg thx, learned a new english word :). was just thinking can it be handy if you could select multiple values in the filter?. So when you go to eventlist or other view, click at the filter, you can tick multiple values to search, fill in a word to search and press search?.

It's possible to retrieve the ticked values and accordingly you can do something with that in the model. // it's like ticking the categories for an event in the backend but a little bit different.

neyworg commented 11 years ago

Drop down filters are now tied to $jemsettings->show____ I understand and agree

However in my case I will have to immediately modify JEM to have filters work like I want. /if ($jemsettings->showcat == 1) { $filters[] = JHTML::('select.option', '4', JText::_( 'COM_JEMCATEGORY' ) ); }/ $filters[] = JHTML::('select.option', '4', JText::( 'COM_JEM_CATEGORY' ) );

I do not want to show the category column, however I want to filter it.

?filter=4&search=clinics&filter=5&search=iowa

I am going to close this, because it is working as it should and can easily be modified to suit needs. We can handle this via HOWTO modification document.