Page 1 sur 1

Collector 0.4.0 showing all

Posté : lun. 16 mai 2011 20:11
par Being
Hello,
In the front-end when I go to Collector all items are listed. If I search for nothing, all items are listed. How can I stop both please?

Tim

Re: Collector 0.4.0 showing all

Posté : mar. 17 mai 2011 18:51
par steevo
Hi,

By default, collector display all items.
In the component parameters (or menu item parameters), you can disable the parameter "Show entire listing".

Re: Collector 0.4.0 showing all

Posté : mar. 17 mai 2011 19:58
par Being
Thanks Steevo,

That fixed it.

Tim

Re: Collector 0.4.0 showing all

Posté : mar. 17 mai 2011 21:52
par Being
One further question please.

How can I prevent people from searching for any word in an item's fields?

I want them only to be able to search for a specific item id, not date, description etc..

Thanks,

Tim

Re: Collector 0.4.0 showing all

Posté : mar. 17 mai 2011 22:52
par steevo
The only way for this is to hack code...
If you're using only one collection and just want to search for a specific field, that could be easy.
In the file components/com_collector/models/collection.php
at line 347
replace

Code : Tout sélectionner

foreach ($fields as $field)
		{
			if ( $field->type == 3 )
			{
				$nameFilterCollection = 'filterfield_'.$field->id;
				$valueFilterCollection = $this->_collection->parameters->get( $nameFilterCollection, 0 );
				
				$filter_field = $reset ? $valueFilterCollection : $mainframe->getUserStateFromRequest( $option.'.collection.filter_field_'.$field->id, 'filter_field_'.$field->id, '', 'int' );
				
				if ( $filter_field != '' )
				{
					$this->_search = 1;
					$where .= ' AND v'.$field->id.'.value = "'.$filter_field.'"';
				}
			}
			if ( $search_all_value != '' )
			{
				$this->_search = 1;
				if ( $field->type == 3 )
				{
					$where2[] = 'd'.$field->id.'.content LIKE "%'.$search_all_value.'%"';
				}
				else
				{
					$where2[] = 'v'.$field->id.'.value LIKE "%'.$search_all_value.'%"';
				}
			}
		}
by

Code : Tout sélectionner

foreach ($fields as $field)
		{
			if ( $field->type == 3 )
			{
				$nameFilterCollection = 'filterfield_'.$field->id;
				$valueFilterCollection = $this->_collection->parameters->get( $nameFilterCollection, 0 );
				
				$filter_field = $reset ? $valueFilterCollection : $mainframe->getUserStateFromRequest( $option.'.collection.filter_field_'.$field->id, 'filter_field_'.$field->id, '', 'int' );
				
				if ( $filter_field != '' )
				{
					$this->_search = 1;
					$where .= ' AND v'.$field->id.'.value = "'.$filter_field.'"';
				}
			}
		}
		if ( $search_all_value != '' )
		{
			$this->_search = 1;
			$where2[] = 'vID_OF_YOUR_FIELD.value LIKE "%'.$search_all_value.'%"';
		}
replace ID_OF_YOUR_FIELD (the last line) by the id of the field that you want to search on. You can find it in the list of fields in admin interface.

Re: Collector 0.4.0 showing all

Posté : mer. 18 mai 2011 16:27
par Being
Thanks ... that's brilliant. Excellent support!

Re: Collector 0.4.0 showing all

Posté : mer. 18 mai 2011 18:42
par steevo
You're welcome.