0

I have a Drupal 7 installation with about 10 custom types and a custom theme. I have a search form in the site's header displayed with

$block = module_invoke('search', 'block_view', 'form');
print render($block);

This code is in an include file called by my page.tpl.php, it's not actually inside a block.

If there are no search results, the search page displays (mostly) correctly and it uses the search-results.tpl.php template in my theme.

However, if there are search results, I get an unformatted page. It's just the search results (with their associated HTML p tags, etc.) with no site HTML. No head tag, no body tag and none of the custom theme's HTML.

By using advanced search, I have identified, specifically, that one of my custom types is causing this issue. The confusing thing is that this type just has a title and a body text. Other, more complicated types are not causing this issue. When I limit it by type, I get the correct output.

How can I get the search results to show up on a regularly themed page?


EDIT

I have also tried:

echo drupal_render(drupal_get_form('search_form'));
1
  • Don't think this is related to the search. Sounds like you get a PHP error on the custom content type. Have you checked the error log for clues? Might be some required data missing for the output.
    – dxc
    Dec 4, 2012 at 20:22

1 Answer 1

1

I don't know if this will help anyone; but, just in case, here is the solution to my problem.

One of my content types (the one causing the issue) is only viewable in the public site via ajax. As such, I had this code in my function *mytheme_node_view_alter(&$build)*

//show only output for popup
if($build['#node']->type=="blue_pop_up"){
    echo $build['#node']->body["und"][0]["safe_value"];
    die();
}

This was breaking my search results page when it found content of this type. I simply added this to the code:

//show only output for popup
    if($build['#node']->type=="blue_pop_up")
    {
        if($build["body"]["#view_mode"] != "search_result")
        {
            echo $build['#node']->body["und"][0]["safe_value"];
            die();
        }
    }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.