I've installed the Drupal 7 version, however, while I have the search box in the header, I would like the ability to display the results in the "Featured" block. Is there a way to do this?

Comments

dsevcik’s picture

Is it a matter of taking this piece of code:

<div id="google-cse-results">
  <noscript>
    <?php print $noscript; ?>
  </noscript>
</div>

from google_cse_results.tpl.php and moving it into our main template in our themes folder?

dsevcik’s picture

This worked!!! For anybody who has this problem, I picked out this section from google_cse_results.tpl.php:

<div id="google-cse-results">
  <noscript>
    <?php print $noscript; ?>
  </noscript>
</div>

<?php if ($suffix): ?>
  <div class="google-cse-results-suffix"><?php print $suffix; ?></div>
<?php endif; ?>

and I dropped it into the section on my main template, node.tpl.php right after the content block starts.

This keeps the search box in the header, keeps the side menus intact, but lets you put the results in whatever block you want. I'm not sure if there is a better/easier way to do this, but this worked fairly quickly.

The only remaining issue, which is small is, I may need to detect in the url if there is a "?cx=", and if so, stop the rest of the content module from displaying in my template so that the rest of it is not pushed down, but rather, not shown.

I'll post here if we try that.

jlea9378’s picture

This worked for me on Marinelli theme, all in page.tpl.php:

<?php if ($title): ?>
            <?php if (empty($_GET['cx'])): /* Google Search Result */ ?>
              <h1 id="page-title"><?php print $title; ?></h1>
            <?php endif; ?>
          <?php endif; ?>
          <!--start drupal content-->
          <div id="content">
            <?php /* Google search */ ?>
              <div id="google-cse-results">
              <noscript>
              <?php print $noscript; ?>
              </noscript>
              </div>
            <?php /* End Google search */ ?>

            <?php if (empty($_GET['cx'])): /* Google Search Result */ ?>
              <?php print render($page['content']); ?>
            <?php endif; ?>
          </div>
          <!--end drupal content-->

          <?php if (empty($_GET['cx'])): /* Google Search Result */ ?>
            <?php print $feed_icons ?>
          <?php endif; ?>

jlea9378’s picture

Status:Active» Needs review

I think this mystery is solved.

jlea9378’s picture

I was getting a PHP notice related to the $noscript variable being undefined, so I added this and it solved the problem:

<?php
 
if (!isset($noscript)) $noscript = "";
?>

Here's what my code looks like:

          <!--start drupal content-->
          <div id="content">
            <?php if (!empty($_GET['cx'])): /* Google Search Result */ ?>
            <?php if (!isset($noscript)) $noscript = ""; ?>
              <div id="google-cse-results">
              <noscript>
              <?php print $noscript; ?>
              </noscript>
              </div>
            <?php endif;/* End Google search */ ?>

I tested it out and it works.

almamun’s picture

Issue summary:View changes

Hey jlea9378,

Your code worked for me.
Pls accept a huge thanks!