Hi,

I'm trying to get my Search window to open in a popup. I've read through the README file, but I can't see how it is possible.

Using this page from the Handbook I can add unique id's to the menu items, but they get put in the <li> rather than the <a>.

I'd really appreciate if someone could explain a good way to get a popup from a menu link or modify the Handbook code to put the unique id into the <a> tag.

Many thanks!

Comments

gmak’s picture

I've got some of this sorted. I figured out how to add the necessary id to the <a> tag, but my pop-up isn't showing. Here's what I've done:

1. add id="Search" to the <a> so that the link looks like:
<li class="leaf active-trail"><a href="/search" id="Search" title="" class="active">Search</a></li>

2. added this to the page.tpl.php file:

<?php //add popup elements
popups_add_popups(array(
	'#Search'
	)
	);
?>

but I'm not getting any sort of pop-up.

Any suggestions?

gmak’s picture

I seem to be answering my own questions as fast as I come up with new ones.

Here is the code that I have used to generate the appropriate menu links. It is placed in the template.php file:

function phptemplate_menu_item($link, $has_children, $menu = '', $in_active_trail = FALSE, $extra_class = NULL) {
  $class = ($menu ? 'expanded' : ($has_children ? 'collapsed' : 'leaf'));
  if (!empty($extra_class)) {
    $class .= ' '. $extra_class;
  }
  if ($in_active_trail) {
    $class .= ' active-trail';
  }
  $id = preg_replace("/[^a-zA-Z0-9]/", "", strip_tags($link));
  if($id=="Search"){
       $link = '<a href="/search" class="popups-form">Search</a>';
  }  
return '<li class="'. $class .'">'. $link . $menu ."</li>\n";
}

This allows me to use the 'scan all pages for popups' setting. (Wasn't having much success in getting the id attribute method to work).

This allows me to open the search page in the popup, but there are a couple of issues:

1. The 'Advanced Search' options are not available, as the link seems to get killed by being in the popup.

2. I can't seem to get search results to show up in the main page. The search is executed, but results show up in the popup. Clicking on a search result returns back to the main page with the selected node.

So, my questions now are:

How can I get the Advanced Search options active again?

How can I get the initial search results to show up in the main page, rather than the popup?

Many thanks.
(Very cool module, by the way)

starbow’s picture

#1: Yeah, you can't use "popups_add_popups" in a .tpl file, or the template.php. This is unfortunate, but I don't know if there is anyway to get around it. Maybe in Drupal 7. I have modified the README file to make this more clear.

#2: No idea about Advanced Search.
You might be able to get the search to act the way you want by setting the "forceReturn" option to the search results page, using: "on-popups-options" = "{forceReturn: 'search/node'}". But, drat, the search results page does not have fixed url, instead it is "search/node/foo". Hmm. Well, try it with a single results page, and if it works, let me know and I will look at changing forceReturn to use a regular expression.