It makes sense to be able to search by author and the creation date for a site with many nodes. This patch will add the ability to search by the author and creation date.

We need to consider if and how this should be supported for content types that have their date and author hidden. See #70722: Search results should respect the content type's "Display author and date information." option

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

floretan’s picture

Attaching a revised version of the patch that is relative to the main drupal folder.

robertDouglass’s picture

created-evaluator looks specific to your site. Can you make that a generic Drupal term?

robertDouglass’s picture

-1 to module_exists('js_calendar') as well.

tbartels’s picture

created-evaluator is the name of the form-field for the comparison selector, not site-specific

+ $form['advanced']['created']['created-evaluator'] = array(
+ '#type' => 'select',
+ '#title' => t('Created date comparison'),
+ '#options' => array('' => '---', '<' => 'Before', '=' => 'On', '>' => 'After'),
+ '#multiple' => FALSE,
+ );

Susurrus’s picture

This still needs a reroll minus the js_calendar code.

Susurrus’s picture

Status: Needs review » Needs work
Susurrus’s picture

Status: Needs work » Needs review
FileSize
3.72 KB

I've rerolled to remove the js_calendar part, renamed created-evaluator to created-comparator, and added the searching code for 'author', which was missing.

Still not really a fan of the organization, but I think fixing that would be for a follow-up patch.

Susurrus’s picture

FileSize
3.72 KB

Alright, a few tabs in that patch. Here's a new one without tabs.

There should really be a check for all submitted patches through coder.module to confirm that the coding standards were adhered to. Would probably speed up development time.

Susurrus’s picture

FileSize
3.87 KB

Makes it a little nicer to have the autocomplete feature available for usernames if the user have access user profiles permission.

I would think it'd be easier if the FAPI for textfield could check the menu system for appropriate permissions before attaching autocomplete URLs than having to do the check this way.

Alex72RM’s picture

Maybe it's necessary another revision for Drupal 5.10.

The last part of patch doesn't match node.module:

@@ -1978,6 +2030,15 @@
   if (isset($form_state['values']['language']) && is_array($form_state['values']['language'])) {
     $keys = search_query_insert($keys, 'language', implode(',', array_filter($form_state['values']['language'])));
   }
+  if (isset($form_state['values']['author']) && $form_state['values']['author'] != '') {
+    $keys = search_query_insert($keys, 'author', $form_state['values']['author']);
+  }
+  if (isset($form_state['values']['created-comparator']) && $form_state['values']['created-comparator'] != '') {
+    $keys = search_query_insert($keys, 'created-comparator', $form_state['values']['created-comparator']);
+  }
+  if (isset($form_state['values']['created-date']) && $form_state['values']['created-date'] != '' && strtotime($form_state['values']['created-date']) !== FALSE) {
+    $keys = search_query_insert($keys, 'created-date', strtotime($form_state['values']['created-date']));
+  }
   if ($form_state['values']['or'] != '') {
     if (preg_match_all('/ ("[^"]+"|[^" ]+)/i', ' ' . $form_state['values']['or'], $matches)) {
       $keys .= ' ' . implode(' OR ', $matches[1]);
Susurrus’s picture

This patch isn't for Drupal 5.x, it's for 7.x, as all feature requests currently should be.

Alex72RM’s picture

Status: Needs review » Closed (won't fix)
greg.harvey’s picture

Status: Closed (won't fix) » Needs review

Why was this set to "won't fix"? Looks like a useful addition to node.module to me!

Status: Needs review » Needs work

The last submitted patch failed testing.

narovi’s picture

Version: 7.x-dev » 6.15
petchiappan’s picture

Status: Needs work » Needs review

node.module.patch queued for re-testing.

jhodgdon’s picture

Version: 6.15 » 8.x-dev
Component: node system » search.module

Feature requests at this point are too late for Drupal 7, and much too late for Drupal 6, sorry! Moving to consideration for Drupal 8, and into the search module queue.

greg.harvey’s picture

Why move to search.module? I thought the code to be patched to achieve this resides in node.module...?

jhodgdon’s picture

That is true, but it is search related code and a search feature request. And I am hoping in Drupal 8 that all of the search related code will be in search.module or sub-modues and not in node.module any more. :)

greg.harvey’s picture

Component: search.module » node.module
Status: Needs review » Needs work

@jhodgdon: You're right to bump this to D8, but you're way off with the way Drupal works. Let me explain:

The code we're looking at here will *never* be a part of search.module, because this code is in a hook - it's by design that Drupal allows modules to expose "hooks" to other modules so they can, in turn, manipulate their behaviour. The search module does this by providing a hook called hook_search() so other modules can write their own search interfaces.

A bit more on hooks here: http://api.drupal.org/api/group/hooks - it says allows modules to interact with core, but it's more than that - the hooks system allows modules to interact with other modules, period, whether core or otherwise - but I digress... You get the idea - API code is central to one module but the code to *manipulate* that API is distributed to modules, ones which invoke the original module's hooks.

This issue is looking at the hook_search() implementation for node.module - node_search(). This will always be a node.module issue, because what you're looking at is node.module manipulating the API provided by search.module, so it is incorrect to mark it up as a search.module issue.

Because of this, a lot, if not most "search-related code" will always be distributed to other modules, by design, and search.module is just an API for searching the Drupal database.

Putting back to the correct queue, hope that clears it up for you. =)

jhodgdon’s picture

Component: node.module » search.module

greg.harvey: I know perfectly well how hooks in Drupal work. Please check out people's background before assuming they are inexperienced.

That said, this is a search feature request, whether or not the code will go into the node module. No one who is maintaining the node module issue queue is going to address this, and it will be addressed in Drupal 8 by the maintainer of the search module (me). So if you don't mind, I would like to leave it in the search issue queue, even though the code might end up in the node module.

By the way, we are hoping for Drupal 8 to make a module called search_nodes.module (or something to that effect), pulling out the search hooks from node.module. Please check out #237748: Decouple core search module implementations from node and user module (and turn search/node and search/user to views). and add to that discussion if you are interested.

greg.harvey’s picture

Sorry, it was hard to judge your experience from your post.

Interesting, re: search_nodes.module. I understand now why you're marking it as a search.module, but without the back story it was totally counter-intuitive to mark up a patch for node.module as a search.module patch. I'm sure you understand... ;-)

jhodgdon’s picture

Another issue that has a partial patch for this (which I've just closed as a duplicate): #155254: Search Content by Author

klonos’s picture

I think we should postpone this on #2083717: Convert Search Results to Views (or close it as a duplicate or even make the other issue a META and this one one of its sub-issues).

ianthomas_uk’s picture

jhodgdon’s picture

Version: 8.0.x-dev » 8.1.x-dev

Since 8.0.x-beta1 has been released, our policy at this point is No feature requests until 8.1.x. See #2350615: [policy, no patch] What changes can be accepted during the Drupal 8 beta phase?. Sorry, it's just too late for 8.0.x at this point, so even if we had a viable patch, the core committers would not commit it.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.0-beta1 was released on March 2, 2016, which means new developments and disruptive changes should now be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.