I created a view finder but i have a problem:my finder do not work with "Match all elements" option. I have this response "There are no results to display"
Does anyone has an idea?
here is a code :
array(
'finder_id' => '14',
'base' => 'views',
'title' => 'Rechercher un prestaire',
'description' => '',
'path' => 'finder/14',
'block' => '0',
'settings' => array(
'form_on_page' => 1,
'form' => array(
'prefix' => '',
'suffix' => '',
'button_text' => 'Find',
'go_text' => 'Go',
),
'advanced' => array(
'filter' => 1,
'submission' => 1,
'ahah' => 1,
'ahah_effect' => 'fade',
'element_combination' => '0',
'pager' => '0',
'match' => 'lt',
'goto' => 'best',
'hide_args' => 1,
'arg_sep' => '/',
'show_links' => 0,
'show_admin_links' => 0,
'search' => '0',
),
'views' => array(
'view' => 'prestataires',
'displays' => array(
'query' => 'default',
'output' => 'default',
),
'results' => '0',
'views_args' => array(
'args' => '',
'delimiter' => '/',
),
),
'finder_wizard' => array(
'is_wizard' => 0,
'settings' => array(
'skip_single_choice' => 1,
'invalid_path' => '',
),
),
),
'elements' => array(
'0' => array(
'finder_element_id' => '16',
'finder_id' => '14',
'element' => 'select',
'title' => 'Choisissez un service',
'weight' => '0',
'settings' => array(
'form' => array(
'description' => '',
'prefix' => '',
'suffix' => '',
'default_value' => '',
'required' => 0,
'size' => '',
'multiple' => 0,
'empty' => '',
'empty_text' => '',
),
'choices' => array(
'field' => 'term_data_1.name',
'views' => array(
'args' => '',
'delimiter' => '/',
),
'displays' => array(
'query' => 'default',
),
),
'finder_wizard_step' => array(
'question' => 'Choisissez Un Service',
'response' => 'Vous avez sélectionné !answer',
'empty_path' => '',
),
),
'element_handler' => array(
'#title' => 'Select list',
'#module' => 'finder_optionwidgets',
),
'#_finder_object' => '1',
),
'1' => array(
'finder_element_id' => '17',
'finder_id' => '14',
'element' => 'select',
'title' => 'Choisissez une région',
'weight' => '1',
'settings' => array(
'form' => array(
'description' => '',
'prefix' => '',
'suffix' => '',
'default_value' => '',
'required' => 0,
'size' => '',
'multiple' => 0,
'empty' => '',
'empty_text' => '',
),
'choices' => array(
'field' => 'term_data_2.name',
'views' => array(
'args' => '',
'delimiter' => '/',
),
'displays' => array(
'query' => 'default',
),
),
'finder_wizard_step' => array(
'question' => 'Sélectionnez une région',
'response' => 'Vous avez sélectionné !answer',
'empty_path' => '',
),
),
'element_handler' => array(
'#title' => 'Select list',
'#module' => 'finder_optionwidgets',
),
'#_finder_object' => '1',
),
),
'elements_index' => array(
'16' => 0,
'17' => 1,
),
'base_handler' => array(
'#title' => 'Views finder',
'#module' => 'finder_views',
),
'admin_links' => array(
'finder/14' => 'View \"Path\"',
'admin/build/finder/14/edit' => 'Éditer',
),
'links' => array(),
'#_finder_object' => '1',
)
Can someone help me?
thank you in advance
Comments
Comment #1
danielb commentedLooks to be a bug at a glance - I will check it out further.
Comment #2
wang.liang.com@gmail.com commentedsame problem for me; it even actually throws error if I select only one criteria.
here is my finder:
Comment #3
danielb commentedIt seems that ANDing two WHERE conditions on two joins of the terms table results in two rows being selected, one for each term. I don't know what to do about this.
A working query (match any element):
The bung query (match all elements):
The only difference is that last line.
If you actually look at a query like that without the WHERE condition you can see in the results how the WHERE will never work.
The results are like:
nid: 71
title: A node
term_data_1: fish
term_data_2: NULL
nid: 71
title: A node
term_data_1: NULL
term_data_2: small
Comment #4
wang.liang.com@gmail.com commentedchange your way to create view will generate only one record:
when you add a new field to the view default display, choose 'Taxonomy: All terms' then 'Limit terms by vocabulary', pick the first vocabulary; add other vocabulary in same way.
here is the sql:
but the problem is, even i create view this way, i print the $result by the end of finder_views_finder_find(), but it is still only one term per record.
are you using Views search function? I wonder if that's where the problem is. (I haven't really understood your code and Views2 code yet)
Comment #5
danielb commentedNot quite sure what you mean wang. The way finder uses views is by supplying it's own plugin display (in finder/modules/finder_views/includes) which manipulates the views query.
The only sort of query I can think of that would work is like some sort of subselect or a union of selects but I'm not even sure if views will let me do that.
Comment #6
wang.liang.com@gmail.com commentedthe sql I provided is from the view (attached).
---------
the Views filters work for me now, so I'll use that for now.
Comment #7
wang.liang.com@gmail.com commentedattach my Views export.
Comment #8
danielb commenteddid i mix up those two queries in #3 :/
Comment #9
danielb commentednow how do i get views to give me that subquery as sql :/
Comment #10
danielb commentedPerhaps I should just create more 'element combination' methods which simply combine the results from multiple queries. Ideally this would be intersected sql statements, but a php intersect is likely too.
Comment #11
Anonymous (not verified) commentedIs there any update on this? Unfortunately it is also extremely important for me to get the "match all elements" function working with multiple terms in four different vocabularies (in the block). Thanks!
Comment #12
danielb commentedI work on this for a few hours every weekend, but mostly I hit dead ends or change my mind about how this should work.
Today i was working on comparing the results using PHP, but that seems like far too much trouble.
Now I'm thinking more along the lines of
but I don't even know if that's going to work
It will work in terms of selecting the right nodes, etc.. but I don't know if I can get all the field values to be available in the theme function, and that may be sql version dependant? I have no idea.
Rest assured my work on finder is focused on this issue, and I probably won't release anything else until some solution is implemented.
Comment #13
Anonymous (not verified) commentedOk thank you that this is your top priority! I am sure you will work out a solution.
I'm afraid I can't help you with this, if it is a tough one even for you, but maybe someone else can work on this and help you out a little!
Comment #14
Anonymous (not verified) commentedHi, since I desperately need this I'm now able to further explain my needs, and it would be great if you could tell me if that will be even possible at all (if not I have a real problem):
I have four vocabularies, each with different, multiple-select terms (but a selection or even multi-selection is not required). I don't use the form, I have all four vocabularies in the block in a sidebar.
What I need is OR for a multiple selection within one vocabulary, but an AND when it comes to connecting the vocabularies in the query.
So let's say I have the following vocabularies with its terms:
vocab A: termA1, termA2, termA3, termA4
vocab B: termB1, termB2, termB3
vocab C: termC1, termC2, termC3, termC4, termC5
vocab D: termD1, termD2, termD3, termD4, termD5, termD6, termD7, termD8, .....
I need the Finder to act like a filter, so let's say I select:
(termA1) + (termB2 + termB3) + (termC1 + termC4) + (termD2 + termD3 + termD7)then I need the query to be something like:
select * where term = (termA1) AND (termB2 OR termB3) AND (termC1 OR termC4) AND (termD2 OR termD3 OR termD7)
I hope it's at least somewhat clear what I mean. Please tell me this will be possible :-/
Thank you!
Comment #15
danielb commentedyeah the plan is to make it flexible enough to do that
Comment #16
Anonymous (not verified) commentedGreat, thank you again! Very much indeed :)
Comment #17
Anonymous (not verified) commentedHi danielb,
since I'm really running out of time I would like to kindly ask if there is any progress on this bug?
I also would like to offer some help if you don't find the time, maybe I can help you out with SQL queries.. at least I could try if you give me a starting point.
Thanks again!
Comment #18
danielb commentedit was just holidays and i've had the flu and I'll be honest.... this is not a fun issue
Comment #19
danielb commentedI'll tell you basically what i've done so far
Starting with finder.admin.inc I've changed the element_combination setting like so:
So options 0 and 1 are still the same, they just have a different description. The new option we need to implement is option 2.
For now I am happy to only implement this in Finder Views. (Finder Node and Finder User can completely remove the 'Intersect' choice from the admin form with form alter, for all I care - these modules are probably not complicated enough yet to require an implementation of this)
In finder_views.module in finder_views_finder_find()
right after
I have put
which is just a placeholder for where I think the implementation should go.
The plan is that, instead of following through and doing the view the normal AND/OR way, it will get each subquery sql (as in - each sql query to get the results for each finder element), using views, and build a query out of that (something like the format I gave in post #12). I don't know whether to try and reuse the function finder_views_finder_find() for that purpose, or create a totally new function to get the subqueries. I have already discovered I can change the last couple lines of finder_views_finder_find() to return the SQL code from the built view, rather than executing the SQL and giving results:
My head is in a totally different place at the moment, but I will try to get back on track and at least attempt to do what I am talking about.
I don't know if I gave all the information I have, there is also a lot of crap in my module from when I tried to combine the element results with PHP - which wound up being a big mess.
Comment #20
danielb commentedI worked on it a few hours today, I made more changes to finder_views_finder_find() and the file finder_views_plugin_display_finder.inc
it's on track, but damn it's mid afternoon and I'm over it
I don't feel like I'm at a point where I can commit my changes yet. My intention is to do a commit in the next few days that will bring the CVS up to speed with what I'm doing.
Comment #21
danielb commentedwell it seems to work in my basic use-case, I'll commit this today so you guys can try it soon
Comment #22
Anonymous (not verified) commentedHi danielb, I just checked back and am really happy to see your response, again I very much appreciate your speedy effort (of course there were the holidays, and I hope you are well again)!
Of course I will try your work out as soon as it is commited and tell you my results/experience! Indeed it seems very complex and I definitely believe you that this is not a fun issue at all. So I will just see how your changes will work, if I should experience any problems I will tell you so and look into it myself. :)
Comment #23
Anonymous (not verified) commentedOk, thanks for uploading!
So, unfortunately I get a query-error when using the new intersect-option of the Finder. Does this error say anything to you? I already did a Google search for "Operand should contain", but it seems like there could be several things causing this error, maybe you can see it right away?
I selected one term ("Eltern") from my first vocabulary and one term ("5. - 10. Jahrgang") from my second vocabulary (I have four vocabularies), but it doesn't seem to make any difference how many terms I select, I tried quite a lot variations.
Here are the two errors:
user warning: Operand should contain 1 column(s) query: SELECT COUNT(*) FROM (SELECT node.nid AS nid FROM node node LEFT JOIN term_node term_node ON node.vid = term_node.vid LEFT JOIN term_data term_data_1 ON term_node.tid = term_data_1.tid AND term_data_1.vid = 1 LEFT JOIN term_data term_data_4 ON term_node.tid = term_data_4.tid AND term_data_4.vid = 4 LEFT JOIN term_data term_data_2 ON term_node.tid = term_data_2.tid AND term_data_2.vid = 2 LEFT JOIN term_data term_data_3 ON term_node.tid = term_data_3.tid AND term_data_3.vid = 3 WHERE ((node.status <> 0 OR (node.uid = 1 AND 1 <> 0) OR 1 = 1) AND (node.type in ('inhalt'))) AND (((node.nid IN (SELECT node.nid AS nid, node.created AS node_created, node.sticky AS node_sticky FROM node node LEFT JOIN term_node term_node ON node.vid = term_node.vid LEFT JOIN term_data term_data_1 ON term_node.tid = term_data_1.tid AND term_data_1.vid = 1 WHERE ((node.status <> 0 OR (node.uid = 1 AND 1 <> 0) OR 1 = 1) AND (node.type in ('inhalt'))) AND ((term_data_1.name = 'Eltern')) ORDER BY node_created DESC, node_sticky DESC ))) AND ((node.nid IN (SELECT node.nid AS nid, node.created AS node_created, node.sticky AS node_sticky FROM node node LEFT JOIN term_node term_node ON node.vid = term_node.vid LEFT JOIN term_data term_data_4 ON term_node.tid = term_data_4.tid AND term_data_4.vid = 4 WHERE ((node.status <> 0 OR (node.uid = 1 AND 1 <> 0) OR 1 = 1) AND (node.type in ('inhalt'))) AND ((term_data_4.name = '5. - 10. Jahrgang')) ORDER BY node_created DESC, node_sticky DESC ))) AND ((node.nid IN (SELECT node.nid AS nid, node.created AS node_created, node.sticky AS node_sticky FROM node node WHERE (node.status <> 0 OR (node.uid = 1 AND 1 <> 0) OR 1 = 1) AND (node.type in ('inhalt')) ORDER BY node_created DESC, node_sticky DESC ))) AND ((node.nid IN (SELECT node.nid AS nid, node.created AS node_created, node.sticky AS node_sticky FROM node node WHERE (node.status <> 0 OR (node.uid = 1 AND 1 <> 0) OR 1 = 1) AND (node.type in ('inhalt')) ORDER BY node_created DESC, node_sticky DESC )))) ) count_alias in /Applications/XAMPP/xamppfiles/htdocs/sites/all/modules/views/includes/view.inc on line 729.and
user warning: Operand should contain 1 column(s) query: SELECT node.nid AS nid, term_data_1.name AS term_data_1_name, term_data_1.vid AS term_data_1_vid, term_data_1.tid AS term_data_1_tid, term_data_4.name AS term_data_4_name, term_data_4.vid AS term_data_4_vid, term_data_4.tid AS term_data_4_tid, term_data_2.name AS term_data_2_name, term_data_2.vid AS term_data_2_vid, term_data_2.tid AS term_data_2_tid, term_data_3.name AS term_data_3_name, term_data_3.vid AS term_data_3_vid, term_data_3.tid AS term_data_3_tid, node.created AS node_created, node.sticky AS node_sticky FROM node node LEFT JOIN term_node term_node ON node.vid = term_node.vid LEFT JOIN term_data term_data_1 ON term_node.tid = term_data_1.tid AND term_data_1.vid = 1 LEFT JOIN term_data term_data_4 ON term_node.tid = term_data_4.tid AND term_data_4.vid = 4 LEFT JOIN term_data term_data_2 ON term_node.tid = term_data_2.tid AND term_data_2.vid = 2 LEFT JOIN term_data term_data_3 ON term_node.tid = term_data_3.tid AND term_data_3.vid = 3 WHERE ((node.status <> 0 OR (node.uid = 1 AND 1 <> 0) OR 1 = 1) AND (node.type in ('inhalt'))) AND (((node.nid IN (SELECT node.nid AS nid, node.created AS node_created, node.sticky AS node_sticky FROM node node LEFT JOIN term_node term_node ON node.vid = term_node.vid LEFT JOIN term_data term_data_1 ON term_node.tid = term_data_1.tid AND term_data_1.vid = 1 WHERE ((node.status <> 0 OR (node.uid = 1 AND 1 <> 0) OR 1 = 1) AND (node.type in ('inhalt'))) AND ((term_data_1.name = 'Eltern')) ORDER BY node_created DESC, node_sticky DESC ))) AND ((node.nid IN (SELECT node.nid AS nid, node.created AS node_created, node.sticky AS node_sticky FROM node node LEFT JOIN term_node term_node ON node.vid = term_node.vid LEFT JOIN term_data term_data_4 ON term_node.tid = term_data_4.tid AND term_data_4.vid = 4 WHERE ((node.status <> 0 OR (node.uid = 1 AND 1 <> 0) OR 1 = 1) AND (node.type in ('inhalt'))) AND ((term_data_4.name = '5. - 10. Jahrgang')) ORDER BY node_created DESC, node_sticky DESC ))) AND ((node.nid IN (SELECT node.nid AS nid, node.created AS node_created, node.sticky AS node_sticky FROM node node WHERE (node.status <> 0 OR (node.uid = 1 AND 1 <> 0) OR 1 = 1) AND (node.type in ('inhalt')) ORDER BY node_created DESC, node_sticky DESC ))) AND ((node.nid IN (SELECT node.nid AS nid, node.created AS node_created, node.sticky AS node_sticky FROM node node WHERE (node.status <> 0 OR (node.uid = 1 AND 1 <> 0) OR 1 = 1) AND (node.type in ('inhalt')) ORDER BY node_created DESC, node_sticky DESC )))) ORDER BY node_created DESC, node_sticky DESC LIMIT 0, 10 in /Applications/XAMPP/xamppfiles/htdocs/sites/all/modules/views/includes/view.inc on line 755.I'll continue looking into it, too!
EDIT: Just one of quite a few posts I found on this, I don't know if it helps:
http://www.sitepoint.com/forums/showthread.php?t=632033#
EDIT 2: Or maybe those?
http://www.webmasterworld.com/php/3889874.htm
http://www.webmasterworld.com/php/3684277.htm
Comment #24
danielb commentedI reckon I know what to do - reset the fields when doing the subqueries and prevent any more from being added in
Comment #25
Anonymous (not verified) commentedI trust you on that ;) Of course I will try every change you make ASAP.
Comment #26
danielb commentedOK so the reason I didn't see this problem before is because my view doesn't use the 'sort' stuff. It's not the fields I need to remove, but the sorts. I have updated the module to fix that problem specifically. Should appear in the dev soon.
Comment #27
Anonymous (not verified) commentedGreat!! As promised, I will test as soon as I can and give you the appropriate feedback. Thanks!
Comment #28
Anonymous (not verified) commentedOk, we are getting there! Your fix worked, the error message is gone. Also, the intersection is "somewhat" working.. let me explain:
It seems like the "intersect" (AND connection between the vocabularies, OR connection within the vocabularies) is basically working. I tried several combinations, e.g. selecting one term from the first vocab and one from the second (ignoring the other two). I do get an result only containing at least both of those terms. If I additionally select more terms from the second vocabulary which are not in that result, I still get the same node as a result, which is perfect.
BUT: for now, I only get one result, no matter how many there are. I think it's always only the first node matching the query. If I select all three terms of my first vocabulary and nothing else, I should get every node that I have. However I also only get one node as a result, the first one matching.
I hope that's easy to locate? :)
Comment #29
danielb commentedI was getting all the results. You sure there isn't an unrelated problem or setting causing that? I would have to be able to reproduce your problem to solve it.
Comment #30
danielb commentedPS, turn finder's caching to 0 in case it is intefering while you're changing the settings around and stuff.
Comment #31
Anonymous (not verified) commentedYou made it.. thanks so much danielb! I've tested for about 10 minutes now, it was all like expected. It seems like the Finder can now work perfectly as an highly adjustable taxonomy search engine and filter.
The reason why I was getting only one result is a VERY weird issue with the pager, and for now I can't get it to work. However, since I haven't read of pager problems so far, maybe this is more of a problem with my theme/view and not your module? I will explain briefly just in case it's an issue with the Finder:
When I set the pager for the Finder to anything else than 0 (unlimited, meaning no pager) I get only one node on the first page of the results. Like this wouldn't be weird enough, I get the same node on the second page, plus the next result, and so on.
Show case: If I get four nodes as a result, I get six result pages. Node #1 on the first page, #1 + #2 on the second, #2 + #3 on the third, ONLY (?) #3 on the fourth, #3 + #4 on the fifth, and finally only #4 on the last page.
Like I said, very weird. From my understanding my view settings are correct, I've set the pager for the result-view display to unlimited just as you say in the advanced pager settings. So it only works for me if I disable the pager. I get all results without pages then. That's not perfect, but better than nothing for now.
And like I said, don't bother if this not an issue with the Finder, you've helped me a lot (!) by implementing the intersect-option. And I think that option is working now as it should :)
Comment #32
danielb commented(There are indeed problems with finder's pager, there is another issue about it, for example if you're selecting multiple fields per element.)
Comment #33
Anonymous (not verified) commentedAh ok, so it's not me.
I'm not going to ask anything from you again ;-) I think I can disable the pager for now. But you have my error description, so I'm looking forward to any Finder improvement, especially concerning the pager. I honestly think it's one of the best drupal modules out there, so I'm sure a lot of users appreciate your work already!
In case I experience any bugs using the new intersect feature, I will tell you immediately for further improvement! But so far I haven't :)