Search

A new Extension, “Publish Filtering” is now available for download. Comments and feedback can be left here but if you discover any issues, please post it on the issue tracker.

I got a bit sick of having to manually search through 700+ pages of entries on a particular site at work, so I made this. Basically it adds a form to each publish index page from which you can choose a field and enter a value to search for.

Version 1.002, 26 February 2009:

  • Improved the interface considerably.
  • Fixed bug where SectionManager class was not included.

Version 1.001, 26 February 2009:

  • The initial release, enjoy!

Wow! This will be great! Thanks so much!

I just downloaded your extension and I'll get a few errors. The script

<script type="text/javascript" src="blabla/symphony/extension/publishfiltering/filters/?section=artikel"></script>

results in this error:

<br />
<b>Fatal error</b>: Class 'SectionManager' not found in <b>/www/htdocs/w008e2fa/pompodium/extensions/publishfiltering/content/content.filters.php</b> on line <b>17</b><br />

I'll get a few javascript errors, too, but this is certainly a consequence of the problem above.

PS: I tried version 1.001 and your current master.

Nils, thanks for pointing that out, I'll make another release in a couple of minutes which is much improved :)

Ok, done!

Great - the errors are gone and everything is working fine :)

Two remarks:

  • It seems like the search only returns exact matches. What about using a live search with quicksilver style?
  • We had a system wide search in Symphony 1.7. What about reintroducing the drawer and the widget icon?

Symphony 1.7 Drawer

The field your searching against dictates how the search is handled, so unfortunately there isn't much I can do about that.

It is possible however to use regexp: on text fields to no in-exact searches, but you'll need to patch your Symphony first. Change line 64 of symphony/content/content.publish.php from:

list($field_handle, $filter_value) = explode(':', $_REQUEST['filter']);

Into:

list($field_handle, $filter_value) = explode(':', $_REQUEST['filter'], 2);

I'm not too keen on the drawer thing, it seems to make sense to keep it inline, and the live search is out of the question since I can't change how the results are displayed.

One thing I think complex fields might need is a function to take a plain value then convert it into whatever they are expecting, for example, it sucks to have to use the entry ID when searching a select box link field.

I think some work needs to be put into making the filtering code (which is part of Symphony) more flexible.

Yep, I found that I needed to add SectionManager to the filters page to suppress the error:

require_once(TOOLKIT . '/class.sectionmanager.php');

I am also finding that the filter appears on entry pages too (edit/new), not just on the publish index. Something like this might do it:

in_array(Administration::instance()->Page->_context['page'], array('new', 'edit'))

A partial match would be amazing! Although time consuming, since the Symphony filter querystring doesn't support this. Sequel Pro's implementation of this is sweet:

Sequel Pro UI

Yeah, Sequel Pro is what gave me the idea for this interface, unfortunately it's not possible to ask a field what types of comparisons it supports. So for now you have to write it all by hand.

I think that's another todo right there.

can this same logic be used for front end searches? or since this only returns exact matches, it'd be hard to translate it to do the front end ones?

There's a topic where I've been discussing advanced searches with Symphony. You can find it here: http://symphony21.com/forum/discussions/704/1/

Rowan, I've added in partial matches — you should have a pull request waiting for you.

It's filtering only english letters :( I think there is a regexp that cuts off non-english letters. How can I fix it?

Can you give us an example consolamentor? It could be that characters are not being URL encoded to/from the querystring.

Example:

Search in input field "organizaton":

Organization contains Юпитер

Returned page URL:

/?filter=organization:regexp:%u042E%u043F%u0438%u0442%u0435%u0440

This is a really useful extension, great work!

One suggestion, could the filter parameters change dynamically depending on what field you choose to filter by?

  • For example if you choose to filter by data stored in a Checkbox field - instead of having to type 'Yes' in the text input - you could provide a dropdown with 'Checked' or 'Unchecked'.

  • Taking that a step further, if you choose to filter by a fieldSelect Box field - for example a list of genres - you could dynamically populate a dropdown by which to refine the filter?

JL

I found that consolamentor is right - we have some problems with characters from extended character sets. So the extension is not dealing with UTF-8 properly, I think.

Example:

  • search for the German word "Blödsinn"; your URL will be ...?filter=title:Bl%F6dsinn.
  • you will not find anything
  • change your URL to ...?filter=title:Blödsinn; now you will find the desired result, but in your search field you will find Blödsinn

BTW: You will find your result if you search for "Blodsinn" - MySQL deals this way with language-specific characters.

JavaScript runs the string through escape() before appending to the querystring. Perhaps encodeURI() and unencodeURI() should be used instead. I'll investigate.

I fixed the language encoding problem by using encodeURI and decodedURI instead of escape and decode in the JavaScript.

Jean-Luc, I've also added the ability for the "value" input field to be converted into a select box when pre-filled options exist for fields. For checkboxes the values Yes and No are used, and for other fields (select box, taglist, selectboxlink; anything that creates a select box in the Publish form!) these values are pulled across.

Text:
Text input

Checkbox:
Checkbox

Select box:
Select box

Version 1.003, 22 April 2009:

http://github.com/nickdunn/publishfiltering/tree/master

Works great, thank you!

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details