Page 1 of 1

Filtering in the back end

Posted: 10 Oct 2010, 23:10
by actioncs
Hi Jan

I am using a very large number of categories. I know there is a "fill out yourself" filter but it would be very useful ( and quicker ) to have a filter with a drop down filtering menu like Joomla has for articles etc. ie giving access to the category tree. Unless there is a tool for doing this and I cannot see it.

many thanks

Wayne

Re: Filtering in the back end

Posted: 11 Oct 2010, 15:46
by Jan
Hi, I don't understand correctly what you mean. Which view you mean?

Re: Filtering in the back end

Posted: 11 Oct 2010, 23:28
by actioncs
It's in the "Phoca Gallery Categories ". It would be useful to filter by parent categories and different sub category levels below them via a drop down, similar to the filter on the "Phoca Gallery Images ".

I have fifty or so categories but most are sub categories and sub sub categories even sub sub sub categories.
I know there is a filter input field but some categories are very long to type in.

eg On the Land>>2010 Rodeo championship>>Bull Riding Finals 20.10.2010

I hope you see what i mean ?

I's not a big issue and I might seem a bit lazy but it would help with workflow.

Many thanks

Wayne

Re: Filtering in the back end

Posted: 17 Oct 2010, 13:56
by Jan
Hi, there was the select box for displaying only specific category, the problem is, categories are stored in tree, so there were some unexpected problems with this filtering and it produces outcomes which can be confusing for users, this is why it was removed from there. So I think this needs to be customized to fit exactly your needs :-(

Jan

Re: Filtering in the back end

Posted: 10 Jun 2011, 11:24
by dethisandthat
I noticed when a filter word is given, the SQL actually returned the correct dataset but in the function _categoryTree, those dataset is eliminated. Instead of trying to play around the recursive function _categoryTree, I let the SQL to retrieve all categories regardless of the filter word and looping through the array to filter base on the filter word.

Below is my code changes:

Phoca Gallery version 2.7.4
File: \Joomla\administrator\components\com_phocagallery\models\phocagallerycs.php

Code: Select all

	function _buildContentWhere() {
		blah blah

		//~ we want to retrieve all datas then later filter the element by $search using code
		//~ if ($search) {
			//~ $where[] = 'LOWER(a.title) LIKE '.$this->_db->Quote('%'.$search.'%');
		//~ }
		if ( $filter_state ) {

Code: Select all

	function getData() {
		global $mainframe;
		if (empty($this->_data)) {
			blah blah

			$this->_data = $this->_categoryTree($this->_data, $tree, 0, $text, -1);

			//added begin
			$search= $mainframe->getUserStateFromRequest( $this->_context.'.search', 'search', '', 'string' );
			$search= JString::strtolower( $search );

			//filter the result with $search text
			$this->_data = $this->filterArray($this->_data, $search);
			//added end
			return $this->_data;
add the function filterArray inside the phocagallerycs.php

Code: Select all

    //~ return a copy of $collection which is filtered by $filterText
    function filterArray($collection, $filterText) {
        if ($filterText=='') {
            return $collection;
        }
        foreach($collection as $key=>$value){
            if (stripos($value->title, $filterText)===FALSE)
                  unset($collection[$key]);
            }
        return $collection;
    }

Re: Filtering in the back end

Posted: 10 Jun 2011, 16:02
by Jan
Hi, thank you for this guide, I will take a look at it.

Jan

Re: Filtering in the back end

Posted: 01 Oct 2013, 12:36
by apictapx
Have a situation with more than 700 categories and search function was important.
Thanks, dethisandthat. Made some updates in code for version 3.2.6 and Search filter became to work for categories with any level.

Re: Filtering in the back end

Posted: 02 Oct 2013, 00:08
by Jan
Ok, will be great to get info about the changes.

Jan