Does anyone have any idea why when I do a search, only the the first page is shown, and none of the pager links show, although I know there are more than one pages, because as soon as you logout, and search as an anonymous user, all the links show up.

I have looked through all the modules and cannot find anything useful, so I have come here to ask for help

thanks.

Comments

lammmy’s picture

anyone? Have any clues as to where to look check out, other than the obvious, pager and search modules/includes?

plumbley’s picture

I don't know if this is related, but I ran into a similar problem myself as a byproduct of one of my own home-grown node types which showed a pager when viewed.(The search page calls hook_view() with $teaser=FALSE and $page=FALSE). I fixed it by making sure my node pagers only appeared on their own page ($page == TRUE).

I'm not completely au-fait with pager magic yet, but my guess is that if a node type itself has the same numbered pager that search is expecting to use (or otherwise there is more than one pager of the same number rendered on a give page) they won't work properly.

Maybe someone more knowledgeable about the pager could help more, but in the meantime it might help to see if any of your node types use pagers in their own display?

Mark
--
www.PostgraduateStudentships.co.uk - where ideas and funding meet

lammmy’s picture

I do have several home-grown types, but know so little about pager, that I have to ask...could you elaborate on your solution a little? Where(what files/functions) and how would you check to make sure $page == TRUE? I'm not really clear on that statement.

Thanks alot for taking the time to answer so far. :)

plumbley’s picture

In my module department.module that implements a "department" node, I have a list of items that match that department. It uses a pager query to limit the number of items displayed when viewing the first page. But any search result listings that included department nodes either had no pager or a pager with 100's of pages when there should be only 3.

I guessed it was something to do with pager since it presumably has to use side-effects or something to communicate between pager_query(), theme_pager() and the ?q=...&page=n GET variable. I've not quite tracked down exactly how it operates yet but ensuring that my own paged list of items were only calculated and displayed within a $page=TRUE condition was enough to fix the problem.

If you follow through the search display, node_search('search',...) calls node_invoke($node, 'view', false, false); - i.e. hook_view with $teaser=FALSE, $page=FALSE. So to be on the safe side, I turn off any paged queries when $page=FALSE. (This will also affect node preview during edit, but that is probably sensible anyway)

So my implementation of hook_view() looks like

function department_view(&$node, $teaser = FALSE, $page = FALSE) {
  [stuff to construct the body or teaser here]

  // If its own page, find and show the funding links
  // NB: If we don't check this, it breaks the search pager
  if ($page) {
    $node->body .= [call function that uses pager_query() and theme('pager',...)]
  }  
  ...
}

I'm guessing that another way to fix this would be to use a different numbered pager ($element parameter to theme_pager()) but I've not tested that yet.

Hope this helps,

Mark.
--
www.PostgraduateStudentships.co.uk - where ideas and funding meet

tara@neier.org’s picture

It defaults the pager element to be 0 overwriting theme_pager's default element of 0 (which is used by the node module). The difference between authenticated and unauthenticated users is usually the ability to view comments. I'm wondering if this bug has been reported or fixed elsewhere.