Frage

I'm trying to use hook_search to extend the built in drupal search to explicitly link two content types.

ex. items a and b are part of collection a. Currently if you search for the title of collection a you only get collection a. I'd like to extend the search so that you get items a & b as well because they are members of that collection.

My code currently looks like:

/** Implementation of hook_search() **/
function event_collection_search($op = 'search', $keys = NULL){
    var_dump($keys); echo '<--keys value';


    switch ($op) {
        case 'search':
            echo 'is this case statement being executed?';
            die; //MORE CODE BELOW BUT IT'S BROKEN BY THIS POINT ALREADY

Right now my code is not going into the 'search' case and also I'm noticing that keys is NULL? What am I doing wrong? How do I extend the search or at the very least access the values I'm searching on?

EDIT: I'm calling 'die' on purpose. Currently I'm expecting the key value to be echoed regardless if the search case is hit or not. Ideally I'd like to see 'is this case statement being executed' echoed as well so I know that the search case is working. Right now NULL is the key value, and the second string is not being echoed back to me. I'm currently only getting the result of the collection node, but not the two items that I have linked to the collection node.

War es hilfreich?

Lösung

Have you looked into http://drupal.org/project/Custom_Search? Not sure if it will be for you but it sounds like it does what you need.

Andere Tipps

Drupal doesn't use a search hook that doesn't return a value for hook_search('name').

I am not sure that you can use echo to test if hook_search('search') is being invoked; if then you are calling die(), it's rather impossible you are seeing anything, as you are interrupting the execution of Drupal before it can render the search results.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top