Project-Id-Version: Trac 0.12
Report-Msgid-Bugs-To: trac-dev@googlegroups.com
POT-Creation-Date: 2008-01-30 09:20+0100
PO-Revision-Date: 2010-07-19 23:05+0200
Last-Translator: Jeroen Ruigrok van der Werven <asmodai@in-nomine.org>
Language-Team: en_US <trac-dev@googlegroups.com>
Plural-Forms: nplurals=2; plural=(n != 1)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Generated-By: Babel 0.9.6

Warning: Can't synchronize with repository "(default)" (Unsupported version control system "git": Can't find an appropriate component, maybe the corresponding plugin was not enabled? ). Look in the Trac log for more information.

Ticket #10 (closed improvement: fixed)

Opened 11 years ago

Last modified 10 years ago

Quick search

Reported by: sebastian Owned by: martin
Priority: minor Milestone:
Component: unspecified Version:
Keywords: search, query Cc: martin@silef.de

Description

To lookup and find a media (or in general some info) is currently tricky. A quick search box in the page layout (e.g. right top) makes a lookup more user friendly.

The search could query different parts of the database like tags, categories, locations, or even comments or user names. The view could list the results ordered by there type with links of further results within the types.

The search should also handle partly queries. E.g. the quick search 'tag' should also reveal media taged with 'phtagr' ;-)

Attachments

quicksearch.diff (15.4 KB) - added by martin 10 years ago.
preliminary patch
quicksearch.2.diff (13.5 KB) - added by sebastian 10 years ago.
Improved initial patch

Change History

comment:1 Changed 11 years ago by martin

  • Cc martin@silef.de added

Just wanted to give feedback, that this enhancement would be very helpful!

comment:2 Changed 10 years ago by martin

  • Owner set to martin
  • Status changed from new to assigned

I'll have a look at it.

comment:3 Changed 10 years ago by martin

I guess I need some help. It seems to be a bit more difficult than expected. I was able to add a query box to the header and named the input field QuickSearch. I was also able to modify the function query() in browser/trunk/controllers/explorer_controller.php so that it would check for $this->data['Media']['QuickSearch'].

What I now planned to do is to simply add the items listed in $this->data['Media']['QuickSearch'] to query for Tags, Categories and Locations simultaneously.

However if I do it like this:

$this->Query->addTag($this->data['Media']['QuickSearch']);
$this->Query->addCategory($this->data['Media']['QuickSearch']);
$this->Query->addLocation($this->data['Media']['QuickSearch']);

it searches for images that would contain the quicksearch values is Tag, Category and Location at the same time, which does not happen too often.

So I tried to output the search results for the queries after another:

$this->Query->addTag($this->data['Media']['QuickSearch']);
$this->_setDataAndRender();
$this->Query->clearTags();

$this->Query->addCategory($this->data['Media']['QuickSearch']);
$this->_setDataAndRender();
$this->Query->clearCategories();

$this->Query->addLocation($this->data['Media']['QuickSearch']);
$this->_setDataAndRender();

which however renders the phtagr page three times.

Is there a way to connect the queries with an "OR"?

Cheers,
Martin

comment:4 follow-up: ↓ 5 Changed 10 years ago by sebastian

First of all, the inputs in CakePHP are notated in Model.field which is assigned to $this->data[Model][field]. E.g echo $form->input('Media.quicksearch'); in the view will be accessible via $this->data['Media']['quicksearch'] in the controller. See Field naming convention in the CakePHP book.

Second the query component is a component which builds and handles the query including URL parameter and SQL statement building (which will be replaced by the branch phtagr-search - anyway).

Third, the function _setDataAndRender() in the controller paginates the current search and renders it. Therefore only the pagination() function of the query component is more appropriate.

For the controller something like the following line should help

// Add tag to the query
$this->Query->addTag($this->data['Media']['QuickSearch']);
// Set variable dataTags for view
$this->set('dataTags', $this->Query->paginate());
// Reset query
$this->Query->delTag($this->data['Media']['QuickSearch']);

$this->Query->addCategory($this->data['Media']['QuickSearch']);
$this->set('dataCategories', $this->Query->paginate());
$this->Query->delCategory($this->data['Media']['QuickSearch']);

$this->Query->addLocation($this->data['Media']['QuickSearch']);
$this->set('dataLocations', $this->Query->paginate());
$this->Query->delLocation($this->data['Media']['QuickSearch']);

In the view you can use than the variables $dataTags, $dataCategories, and $dataLocations which contains the results of the different queries. The data is organized like in find('all') method of a model.

Hope that helps.

Changed 10 years ago by martin

preliminary patch

comment:5 in reply to: ↑ 4 Changed 10 years ago by martin

Thanks for your hints! Helped a lot!

I was able to create a preliminary patch. It does work so far, but there are a few enhancements one should consider:
1) Display of an error when no images were found is not implemented yet.
2) Using OR instead of AND when performing the queries of the given quicksearch values.
3) Only list a few thumbnails and the number of hits together with a "more..." link instead of the full images. Currently all images that match to the quicksearch are listed which can be too much.
4) The quicksearch.ctp file is badly hacked. Maybe I forgot something there.

comment:6 Changed 10 years ago by sebastian

The improved patch quicksearch.2.diff has following changes

  1. Add the possibility to search via /explorer/quicksearch/text
  2. CSS adaption for the form in topnav
  3. Add "show more links" to the view
  4. Fix quick search for multiple values separated by comma. Eg. 'tag1, tag2'
  5. Moved the visibility icon code to the helper image_data to reduce code

Following things needs to be done before a commit

  1. Add functions clearTags(), clearCategories(), clearLocations() to Query component and add these to the quicksearch controller code
  2. Maybe improve the CSS for topnav

Changed 10 years ago by sebastian

Improved initial patch

comment:7 Changed 10 years ago by martin

  • Status changed from assigned to closed
  • Resolution set to fixed

As of revision r440 this is fixed!

Note: See TracTickets for help on using tickets.