When using a select list box to select node type I want to search on, Finder is returning the {name} field instead of the {type} field from the node_type table for the select list option value.

So for example... my select display value is 'Bumper Sticker' the machine readable name option value should be 'bumper_sticker', but finder is trying to search the node {type} field with 'Bumper Sticker' and obviously finding no results.

Ill have to go in and hack this so it works properly, but wanted to call attention to the problem since I didn't find any other posts on the matter.

CommentFileSizeAuthor
#3 bumpersticker.jpg145.26 KBdanielb

Comments

danielb’s picture

Can't reproduce.... finder isn't searching the node_type.type field, it's searching the node_type.name field....

Reevescorp’s picture

Try using 'two word' node types vs 'oneword' node types.... Actually... you are searching node.type using the node_type.name field... which is incorrect. It will work fine with one word node types. Pages, Stories, Articles etc... but when you use two word node types... the node_type.name field becomes "Bumper Sticker' for example... and the node_type.type field becomes "bumper_sticker" When you pull "Bumper Sticker" from node_type.name and you try to search it against node.type... it will fail... because the variable in node.type is "bumper_sticker" not "Bumper Sticker". I suspect the module doesnt really get tested using multiple word node types hence why the problem hasnt been detected before now. I already tested this theory... I changed the human readable name of my node_type.name to 'bumper_sticker' to match the machine readable node_type.type BAM... it worked. Problem there is I dont really want to use 'bumper_sticker in my select list... looks cheesy.

danielb’s picture

StatusFileSize
new145.26 KB

I don't think so mate, plenty of my content types are two/three words, e.g. "Book page".

Just to be certain I created a content type Bumper Sticker with machine name bumper_sticker, and added one node of this type.
Then I created a finder as you described, and it worked fine.

Attached is a screenshot of my test finder. You can see at the bottom a result of the bumper sticker node, after "Bumper Sticker" was selected. At the top you can also see debugging information about the query, which shows node_type.name being the field that is matched and "Bumper Sticker" as the keyword.

IMO, if you are experiencing a bug, then you have not identified the right bug.

Reevescorp’s picture

Query string that doesnt work:

SELECT DISTINCT node.nid, "nid" AS base_field, "node" AS base_table, node.title AS finder_element_3_node_title, node_type.name AS finder_element_4_node_type_name FROM node node INNER JOIN node_type node_type ON node_type.type = node.type WHERE ((node.type IN ('adhesive_decal_10x14','bumper_sticker','button','magnetic_sign') AND ((node.title LIKE '%obama%'))) AND (node.type IN ('Bumper Sticker','','','') AND ((node_type.name LIKE '%%')))) AND node.status = 1 GROUP BY node.nid LIMIT 0, 5

This (node.type IN ('Bumper Sticker','','','') is wrong. Clearly it IS trying to search 'Bumper Sticker' IN node.type which will fail.

If I change the node_type.name to 'bumper_sticker' and rerun the query again

SELECT DISTINCT node.nid, "nid" AS base_field, "node" AS base_table, node.title AS finder_element_3_node_title, node_type.name AS finder_element_4_node_type_name FROM node node INNER JOIN node_type node_type ON node_type.type = node.type WHERE ((node.type IN ('adhesive_decal_10x14','bumper_sticker','button','magnetic_sign') AND ((node.title LIKE '%obama%'))) AND (node.type IN ('bumper_sticker','','','') AND ((node_type.name LIKE '%%')))) AND node.status = 1 GROUP BY node.nid LIMIT 0, 5

Now it works... now it finds all Obama bumper stickers

Just to be clear... I am running two elements. One is a text box for the wording the other is a drop down list for the type.

Also... your screenshot shows the query being called at line 1143.... in my module (6.x-1.10) line 1143 is a blank line:

1143
1144 /**
1145 * Build finder code string recursively.
1146 */
danielb’s picture

Version: 6.x-1.10 » 6.x-1.x-dev

Wait a second, I'm using 6.x-1.x-dev not 6.x-1.10. If the 6.x-1.x-dev version does not fix the problem please post an export of your finder here in an attachment, codeblock or pastebin.

Reevescorp’s picture

Version: 6.x-1.x-dev » 6.x-1.10

Ok... I updated to the dev version.

Still experiencing the same problem

Its still looking in node.type for 'Bumper Sticker'

SELECT DISTINCT node.nid, "nid" AS base_field, "node" AS base_table, node.title AS finder_element_3_node_title, node_revisions.body AS finder_element_3_node_revisions_body, node_type.name AS finder_element_4_node_type_name FROM node node INNER JOIN node_revisions node_revisions ON node_revisions.vid = node.vid INNER JOIN node_type node_type ON node_type.type = node.type WHERE ((node.type IN ('adhesive_decal_10x14','bumper_sticker','button','magnetic_sign') AND ((node.title LIKE '%obama%' OR node_revisions.body LIKE '%obama%'))) AND (node.type IN ('Bumper Sticker','','','') AND ((node_type.name LIKE '%%')))) AND node.status = 1 GROUP BY node.nid LIMIT 0, 5

array(
  'finder_id' => '2',
  'base' => 'node',
  'title' => 'SignageMart Product Locator',
  'description' => '',
  'path' => 'search',
  'block' => '1',
  'settings' => array(
    'form_on_page' => 0,
    'form' => array(
      'prefix' => '',
      'prefix_format' => '1',
      'suffix' => '',
      'suffix_format' => '1',
      'button_text' => 'Search',
      'go_text' => 'Go',
    ),
    'advanced' => array(
      'no_results' => array(
        'no_results' => 'There are no results to display',
      ),
      'filter' => 0,
      'validate_empty' => 0,
      'submission' => 1,
      'ahah' => 0,
      'ahah_effect' => 'none',
      'ahah_remote' => 0,
      'element_combination' => '0',
      'pager' => '5',
      'goto' => '',
      'hide_args' => 1,
      'arg_sep' => ',',
      'empty_symbol' => '',
      'show_links' => 0,
      'show_admin_links' => 0,
      'cache_finder_find' => '0',
      'search' => '0',
      'search_tab' => 'node',
    ),
  ),
  'elements' => array(
    '0' => array(
      'finder_element_id' => '3',
      'finder_id' => '2',
      'element' => 'text',
      'title' => 'Search Products',
      'weight' => '0',
      'settings' => array(
        'form' => array(
          'description' => '',
          'prefix' => '',
          'prefix_format' => '1',
          'suffix' => '',
          'suffix_format' => '1',
          'default_value' => '',
          'required' => 0,
          'field_prefix' => '',
          'field_suffix' => '',
          'maxlength' => '',
          'minlength' => '',
          'size' => '40',
          'rows' => '0',
        ),
        'choices' => array(
          'field' => array(
            'node.title' => 'node.title',
            'node_revisions.body' => 'node_revisions.body',
          ),
          'node_types' => array(
            'adhesive_decal_10x14' => 'adhesive_decal_10x14',
            'bumper_sticker' => 'bumper_sticker',
            'button' => 'button',
            'magnetic_sign' => 'magnetic_sign',
          ),
          'published' => 1,
        ),
        'advanced' => array(
          'delimit' => '',
          'field_combination' => '0',
          'value_combination' => '0',
          'nesting_order' => '0',
          'match' => 'c',
        ),
      ),
      'element_handler' => array(
        '#title' => 'Text',
        '#module' => 'finder_text',
      ),
      '#_finder_object' => '1',
    ),
    '1' => array(
      'finder_element_id' => '4',
      'finder_id' => '2',
      'element' => 'select',
      'title' => 'Products',
      'weight' => '1',
      'settings' => array(
        'form' => array(
          'description' => '',
          'prefix' => '',
          'prefix_format' => '1',
          'suffix' => '',
          'suffix_format' => '1',
          'default_value' => '',
          'required' => 0,
          'size' => '',
          'multiple' => 0,
          'empty' => 'prepend',
          'empty_text' => 'All Products',
        ),
        'choices' => array(
          'field' => array(
            'node_type.name' => 'node_type.name',
          ),
          'sort' => 0,
          'node_types' => array(
            'adhesive_decal_10x14' => 'adhesive_decal_10x14',
            'bumper_sticker' => 'bumper_sticker',
            'button' => 'button',
            'magnetic_sign' => 'magnetic_sign',
          ),
          'published' => 1,
          'per_result' => 0,
          'rewrite' => array(
            'php' => '',
          ),
        ),
        'advanced' => array(
          'delimit' => '',
          'field_combination' => '0',
          'value_combination' => '0',
          'nesting_order' => '0',
          'match' => 'c',
        ),
      ),
      'element_handler' => array(
        '#title' => 'Select list',
        '#module' => 'finder_optionwidgets',
      ),
      '#_finder_object' => '1',
    ),
  ),
  'elements_index' => array(
    '3' => 0,
    '4' => 1,
  ),
  'base_handler' => array(
    '#title' => 'Node finder',
    '#module' => 'finder_node',
  ),
  'admin_links' => array(
    'search' => 'View \"Path\"',
    'admin/build/finder/2/edit' => 'Edit',
  ),
  'links' => array(),
  '#_finder_object' => '1',
)
danielb’s picture

Resetting the "Restrict nodes that can be found to only these content types" on the text field element to 'all' seems to fix it.

Not sure why that's interfering....

danielb’s picture

Without picking content type restrictions on the text field:

SELECT DISTINCT 
   node.nid, 
   "nid" AS base_field, 
   "node" AS base_table, 
   node.title AS finder_element_46_node_title, 
   node_revisions.body AS finder_element_46_node_revisions_body, 
   node_type.name AS finder_element_47_node_type_name 
FROM {node} node 
INNER JOIN {node_revisions} node_revisions ON node_revisions.vid = node.vid 
INNER JOIN {node_type} node_type ON node_type.type = node.type 
WHERE ((node.type IN ('book','bumper_sticker','page') AND ((node_type.name LIKE '%Bumper Sticker%')))) 
AND node.status = 1 
GROUP BY node.nid

With picking content type restrictions on the text field:

SELECT DISTINCT 
node.nid, 
"nid" AS base_field, 
"node" AS base_table, 
node.title AS finder_element_46_node_title, 
node_revisions.body AS finder_element_46_node_revisions_body, 
node_type.name AS finder_element_47_node_type_name 
FROM {node} node 
INNER JOIN {node_revisions} node_revisions ON node_revisions.vid = node.vid 
INNER JOIN {node_type} node_type ON node_type.type = node.type 
WHERE ((node.type IN ('book','bumper_sticker','page')) AND (node.type IN ('Bumper Sticker', '', '') AND ((node_type.name LIKE '%%')))) 
AND node.status = 1 
GROUP BY node.nid

We are missing 3 arguments in the 2nd case - the second set of node types... and the last argument is coming out in the wrong spot... hmmmm

(obviously in my example I'm using different content types than you, because I don't have the same ones you do)

I will look into the code and see how this happens.

danielb’s picture

There is a for loop in finder_node_finder_find() that adds arguments for the type restrictions, however each time it does so it wipes the previous arguments....

oops!

danielb’s picture

Title: Node Type select list using wrong field » Node type restriction breaks the query if used on multiple elements
Version: 6.x-1.10 » 6.x-1.x-dev

Fixed in 6.x-1.x-dev, will also look at 7.x-1.x-dev. Thanks for your persistence!

danielb’s picture

7.x-1.x-dev works too differently to have the same bug.

Within the next 12 hours the 6.x-1.x-dev will be updated with the changes, check the date on the release.

Reevescorp’s picture

Version: 6.x-1.x-dev » 6.x-1.10

Thank you for identifying the issue. At the time of this posting I notice the dev 7 version had been updated but not the dev 6 version (still showing a July 3 release).

danielb’s picture

ugh I must have messed up the commit :/

Reevescorp’s picture

If I had a nickel for every time I saved to the wrong file... I'd be retired to some secluded beach with half naked women serving me frozen drinks with little umbrellas all day long. Btw... thank you for all your hard work providing a superior search module. The functionality of this code is awesome! Heads above the rest.

I do have one more question. Is there a way on this node.type search to make an all of the selected types? For example I dont want to include all node types, I want to only select individual product types... but also give the user an ALL selection to check ALL product types for the search terms?

Regards,

danielb’s picture

Yes when you edit a select/radios/checkboxes element there is a fieldset called 'form element' or something like that. Within that are some options for 'empty choice'. You can label it 'select all' or something like that. Basically what it means if they choose that option; this element won't affect the query, and won't cause any 'restrictions' on the results - which is effectively the same as picking all the options. The settings for node type in the element should still apply.

Reevescorp’s picture

I hate to be a PITA.... but I downloaded the newer code... still having the same problem and I dont see any changes in the finder_node_finder_find() between the old and new code. So Im wondering if you accidentally posted the wrong version?

danielb’s picture

No, the changes are there...

danielb’s picture

Version: 6.x-1.10 » 6.x-1.x-dev
danielb’s picture

Status: Active » Fixed

Pretty sure this is fixed, make sure you're getting the 6.x-1.x-dev version and not re-downloading the broken 6.x-1.10.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

john.chriss’s picture

Component: Finder Node (node.module integration) » Code

I am facing the same problem. Already tried all the given solutions but all in vain, the error is still there..
Any other solution?

________________
I love printing stickers.