Search

In Symphony’s source code there a some helpful tools like a SectionManager, an EntryManager or a FieldManager. Would it be possible to add something like a SearchManager that handles searches across fields (and takes care of their specifics) and that can be called like this:

$search = new SearchManager();
$result = $search->find('cookies');

It would be a tremendous help to have a core search functionality that can search sections on the admin side, that can be used for ajax calls or that can be triggered by front-end events.

I think this is a really good idea.

This feels very similar to a Data Source to me. I wonder whether you could achieve the same result using a custom Data Source. Not by writing a mycustomds.datasource.php file, but instantiating a new DataSource using the DatasourceManager. I do this for the API extension and found it very easy.

What you really want is something like:

$search = new SearchManager();
$search->filter('cookies', array('title', 'body'));
$result = $search->run();

I would think it is more useful to be able to filter based on known field IDs/handles, rather than across all possible fields in a section?

If so, then this feels identical to the innards DataSource which uses the EntryManager. The problem with EntryManager is that it accepts SQL statements for WHERE and JOINs, which the DataSource builds and passes to its EntryManager. If you want to use EntryManager yourself you need to build the SQL strings yourself.

To get around this, yourheropaul wrote DatabaseManipulator as a layer on top of EntryManager.

Perhaps refining DatabaseManipulator would be the best approach, by exposing it as a more user-friendly API.

So many options ;-)

I’ve actually written a datasource that can be used as a generic template for searching a particular section. This has reminded me to release it tomorrow.

How does the search of this website work. Any hidden magic or just custom data base fetching?

Each section has a custom search data source. the DS utilises SQL to determine relevant entries and are weighted accordingly. As I understand it, it’s not hugely complex.

@buzzomatic: any progress on your generic template for searching? I’m need to get some searching functionality and this would be very interesting before diving into custom data source creation myself.

I haven’t seen Rowan for a while, so I hope he doesn’t mind me posting on his behalf. I believe this is the search DS he mentioned. I used it as a guide when writing SymQL so that it provides identical functionality.

I’ve actually rewritten Rowan’s DS to use SymQL (chopping out maybe 100 lines) but SymQL won’t be released until Symphony 2.0.7 or 2.1. Whereas Rowan’s DS will work today.

Thanks for posting those links, Nick. I will try out the search DS. I had a quick glance at the code, and if I understand correctly I have to make a POST request with variable field['fieldname']?

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