Project page: http://drupal.org/sandbox/teppi/1936024
GIT: git clone --branch 7.x-1.x http://git.drupal.org/sandbox/teppi/1936024.git search_exclude_nid
Overview
I had in two different projects the use case where clients wanted to hide some special nodes from the search for various reasons. A common example is a node, which has an embedded view (for instance with the module "Insert view") with a listing of the child nodes. If the output of this node is cached the body content of this node would go into the search index. Then it can happen that a search for a certain string returns the listing page as well as the listed node on the listing page, because a part of the body content of the child node was displayed.
I know it's a quite special use case, but I had to do it already twice, so I thought it might be time to have a module for this. I only found a Drupal 6 module which does basically the same. I put some effort into the Admin UI to make the adding of nodes as simple as possible. The actual functionality of the module is a simple rewrite of the search query.
I'm looking forward to any feedback! :-)
Manual reviews of other applications:
http://drupal.org/node/1995954#comment-7421916
http://drupal.org/node/1996830#comment-7430060
http://drupal.org/node/1997826#comment-7430208
New reviews:
http://drupal.org/node/1993854#comment-7466078
http://drupal.org/node/1990340#comment-7471020
http://drupal.org/node/1987530#comment-7471224
Comments
Comment #1
swim commentedHey Stefan Lehmann,
In search_exclude_nid.install.
Just a suggestion but consider removing your persistent variables via variable_del as you only have a small number regardless.
In search_exclude_nid.admin.inc, line 27.
Nice module, thanks =).
Comment #2
eriknewby commentedHi Stefan,
This module works great! Thanks for this cool contribution.
Here are a few things I found while doing a manual code review:
1. search_exclude_nid.install: To be more standards compliant it's best to use db_delete() instead of db_query here http://api.drupal.org/api/drupal/includes!database!database.inc/function...
2. search_exclude_nid.admin.inc
- I see some strings that are still missing the t() function.
- Why is the link in $nid_add_link capitalized and not wrapped in t()?
- The UI is a tad bit confusing for the form. Initially I kept filling out the autocomplete field and hit "Save configuration". The NIDs weren't getting added because it wasn't clear to me that I needed to click the "+ ADD NID TO EXCLUSION LIST". My guess is this is why you capitalized the letters, but I don't think that's a good idea. This of course is more a UI/UX issue and not a functional issue, so not a blocker. But it would be nice to see a more elegant approach.
3. search_exclude_nid.info: the "configure" path is incorrect.
Comment #3
stefan lehmannHey there! Thanks for the review!
@ hapax legomenon:
@ eriknewby:
Thanks again for the reviews! :-)
Comment #4
klausiComment #5
klausimanual review:
Removing review bonus tag, you can add it again if you have done another 3 reviews of other projects.
Comment #6
stefan lehmannThank you klausi for the review!
I hope to get some additional reviews done during this week. Thanks so far! :-)
Comment #6.0
stefan lehmanncorrected git clone statement
Comment #6.1
stefan lehmannadded another manual review.
Comment #6.2
stefan lehmannadded another link to a review.
Comment #7
stefan lehmannAdding bonus tag again for another 3 reviews I did today.
Comment #8
cybernetikz commentedmanual review:
Nice module Stefan!
line 58: What is this checking for - if (!empty($excluded_nids)) where previous line is enough.
line 80: No point to use intval($nid) where you already have $node->nid
Comment #9
nonzod commentedin admin/config/search/search_exclusion
I think is better to give a more specific name for id in li tag in to the section "List of excluded nodes".
Now is "node-NID", you can change it in something like "excluded-node-NID".
Comment #10
stefan lehmannThanks cybernetikz and nonzod for your reviews.
line 58: What is this checking for - if (!empty($excluded_nids)) where previous line is enough.
Yep true, it's obsolete. I changed the format of the variable at some stage and that's a leftover of the refactoring. Thanks!
line 80: No point to use intval($nid) where you already have $node->nid
True, I use $node->nid now.
I think is better to give a more specific name for id in li tag in to the section "List of excluded nodes".
Now is "node-NID", you can change it in something like "excluded-node-NID".
Hm, ok. I think it's already specific enough, as the outer form already provides the id "search-exclude-nid-search-exclusion-form", but to make you happy I added "excluded-" to the <li>'s id as well. :-)
Thanks for the reviews guys.
Comment #11
nsuit commentedWorked great for me. I used node_access in drupal 6 to achieve what your module is doing, but this or the module for drupal 6 you mentioned would have been so much easier.
Comment #12
swim commentedNot just yet. Changing status to needs review.
Hey Stefan,
In search_exclude_nid.admin.inc, line 35 - 40.
I see your selecting all the nodes which are to be excluded. Maybe this would be more appropriately placed in it's own function, simply returning nid & title of said excluded node(s). This means other devs could reuse this function if need be & it keeps your form function nice & clean.
In search_exclude_nid.admin.inc, line 71.
The description hints at a check,
Possibly implement a validation function for your form as well as the submit callback doing exactly this. E.G. return a form error if something other than an nid is submitted.
The use of the JS is still a little unfamiliar to me as I could see similar functionality achieved with $form_state['rebuild'].
Cheers,
Comment #13
klausimanual review:
The objections in comment #12 also don't seem to be application blockers, and since this was RTBC already ...
Thanks for your contribution, Stefan Lehmann!
I updated your account to let you promote this to a full project and also create new projects as either a sandbox or a "full" project.
Here are some recommended readings to help with excellent maintainership:
You can find lots more contributors chatting on IRC in #drupal-contribute. So, come hang out and get involved!
Thanks, also, for your patience with the review process. Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.
Thanks to the dedicated reviewer(s) as well.
Comment #14
stefan lehmannThanks guys, I will apply your suggested changes, apart from the $form_state['rebuild'], as this probably means quite a lot of refactoring. But I'll have a look tomorrow.
I'm definitely keen to review further projects, if I have some spare time. :-)
Comment #15
stefan lehmannPS: @hapax legomenon, regarding the validation function. I want to make it as simple as possible. That's why I filter the user entries rather, than giving feedback about wrong entries. If people complain about this behavior I'll refactor it, but for now I'd like to leave it like it is. Thx.
Comment #16
swim commentedAhh sorry for bumping this xD.
Of course Stefan mine were just suggestions & your right validation can often get in the way & become a hindrance.
Comment #17.0
(not verified) commentedAdded another review