Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I have been working on creating query exclusions, specifically for content types. This version is preliminary, and accesses the metadata for the bundle names via variables.
Comments
Comment #1
ayang CreditAttribution: ayang commentedNot totally happy with how everything looks right now, but it works!
Comment #2
Nick_vhJust improved it a bit in order to apply the patch more easily.
I suggest you check out the git module and use git diff to create the diffs
Comment #3
Nick_vhSome code format problems :
sites/all/modules/contrib/apachesolr_multisitesearch/apachesolr_multisitesearch.module
apachesolr_multisitesearch.module
Line 139: Control statements should have one space between the control keyword and opening parenthesis
return($query_bundle_names);
(This should actually be return $query_bundle_names)
sites/all/modules/contrib/apachesolr_multisitesearch/apachesolr_multisitesearch.admin.inc
apachesolr_multisitesearch.admin.inc
Line -1: @file block missing (Drupal Docs)
Line 75: Use uppercase for PHP constants, e.g. NULL, TRUE, FALSE
'#multiple' => true,
You should also handle error situations because I tried it and the content types returned empty so I had an empty select list. There is also no description above the select list to tell you what it exactly does?
Could you also explain the TODO item in the code?
Comment #4
ayang CreditAttribution: ayang commentedHi Nick,
Thanks for the feedback. Regarding the TODO statement, the code doesn't allow for any filtering for content from specific sites, just all of the sites as a collective. I am planning on adding another tier for the select list to allow for filtering a specific content type from a specific site.
Comment #5
ayang CreditAttribution: ayang commentedHere is the updated code. It won't render the section of the form if there are no content types present in the metadata and adds a clear button to the query exclusion form.
Comment #6
Nick_vhI'm not sure if this is the way to go? You might want to use form_state instead of form
Same here, can you use form_state or not? If not no worries. Also empty is sufficient enough so you can remove isset
Is there a more performant way to do this?
ew, html in a drupal_set_message. Never fun ;-)
Better check if it is an array and not empty
check if the value is effectively not empty
only empty is enough
Comment #7
ayang CreditAttribution: ayang commentedHi Nick,
Thanks for the continued feedback. Here's the next rendition, built off your notes and cleaned up a bit.
Comment #8
Nick_vhJust to confirm, you could not use form_state compared to form object?
Comment #9
Nick_vhwe need this fix first in 7.x-1.x actually
Comment #10
Nick_vhHm,, committing it first for 6.x-3.x
included patch is for 6.x-3.x and was committed. Thanks Andrew! (but I did change $form to $form_state and fixed some non-encapsulated strings so they are within a t() function now)
Comment #11
Nick_vhCommitted to 7.x-1.x also
Comment #12
Nick_vh