I'd like to add the option to paginate the FAQ pages using the standard Drupal pager. The reason is I have a client who wants to add a lot of faq's (hundreds per category).

Ideally the pager would be configurable so we could choose how many faq's to have on each page just like the Post settings in Drupal.

Currently we are using these options:

  • Clicking on question opens/hides answer under question
  • Display short text
  • Use answer teaser
  • Show node links

I mention this in case you think it will matter what options are chosen wrt adding a pager.

I know I can probably forge this using Views and theming but ideally I would like to have this in the module.

Any thoughts or suggestions?

BTW - great module and kudos to you for the tpl files and theme functions which make it very easy to theme this module, really excellent.

Comments

stella’s picture

Status: Active » Closed (works as designed)

I thought about implementing this feature but I've come to the conclusion that it isn't something that the majority of users will use or need. That, combined with the fact that you can achieve the same result using the Views module, means I won't be adding this feature to the FAQ module.

I will reconsider it if there's more interest from other users in the future.

Cheers,
Stella

Coxus’s picture

Yes, i need this functional too

diegohermes’s picture

I think this feature would be very useful, i don't understand when you say that it can be achieved using views, with views - as far as i know - you can't use de collapse/expand effect in the questions that this module have. If there is a way of use the effect in views, can you please explain?

I created my own faq with CCK + views + custom js file, but i like your module, the only thing that is left, in my opinion, is the pager.

Regards,
Diego

diegohermes’s picture

Status: Closed (works as designed) » Active
Jeff Burnz’s picture

Component: User interface » Documentation
stella’s picture

Component: Documentation » User interface
Status: Active » Closed (works as designed)

Unfortunately I still don't plan on adding this feature. You can achieve pagination using views, and most of the faq module's features. You can't achieve the javascript functionality, but I'm sure you could (or find someone to) write a small bit of jQuery to achieve the same effect.

Cheers,
Stella

Jeff Burnz’s picture

I think the last relevant comment asked "how to do this with views" hence the documentation status, is that a problem? I would write this when I have time, do you not want that contribution here?

redkostia’s picture

To implement pagination is needed to change a little bit faq.module code.
instead of $result = db_query(db_rewrite_sql("SELECT n.nid, if((w.weight IS NULL), %d, w.weight) as weight, n.sticky, n.created FROM {node} n INNER JOIN {term_node} tn ON (n.nid = tn.nid AND n.vid = tn.vid) LEFT JOIN {faq_weights} w ON w.tid = tn.tid AND n.nid = w.nid WHERE n.type='faq' AND n.status = 1 AND tn.tid = '%d' ORDER BY weight, n.sticky DESC, n.created DESC", "n", "nid"), $default_weight, $term->tid);
we should use pager_query

for example

 function _display_faq_by_category($faq_display, $category_display, $term, $display_header, &$output, &$output_answers) {

  $default_sorting = variable_get('faq_default_sorting', 'DESC');
  $default_weight = 0;
      $sql_count = db_rewrite_sql("SELECT count (n.nid) 
      FROM {node} n INNER JOIN {term_node} tn ON (n.nid = tn.nid AND n.vid = tn.vid) 
      LEFT JOIN {faq_weights} w ON w.tid = tn.tid AND n.nid = w.nid 
      WHERE n.type='faq' AND n.status = 1 AND tn.tid = '".$term->tid."' ORDER BY weight, n.sticky DESC, n.created ASC","n","nid");
      $sql = "";
  if ($default_sorting != 'DESC') {
    $default_weight = 1000000;
    $sql = db_rewrite_sql("SELECT n.nid, if((w.weight IS NULL), ".$default_weight.", w.weight) as weight, n.sticky, n.created FROM {node} n INNER JOIN {term_node} tn ON (n.nid = tn.nid AND n.vid = tn.vid) LEFT JOIN {faq_weights} w ON w.tid = tn.tid AND n.nid = w.nid WHERE n.type='faq' AND n.status = 1 AND tn.tid = '".$term->tid."' ORDER BY weight, n.sticky DESC, n.created ASC", "n", "nid");
    //$result = db_query(db_rewrite_sql("SELECT n.nid, if((w.weight IS NULL), %d, w.weight) as weight, n.sticky, n.created FROM {node} n INNER JOIN {term_node} tn ON (n.nid = tn.nid AND n.vid = tn.vid) LEFT JOIN {faq_weights} w ON w.tid = tn.tid AND n.nid = w.nid WHERE n.type='faq' AND n.status = 1 AND tn.tid = '%d' ORDER BY weight, n.sticky DESC, n.created ASC", "n", "nid"), $default_weight, $term->tid);
  }
  else {
  	$sql = db_rewrite_sql("SELECT n.nid, if((w.weight IS NULL), ".$default_weight.", w.weight) as weight, n.sticky, n.created FROM {node} n INNER JOIN {term_node} tn ON (n.nid = tn.nid AND n.vid = tn.vid) LEFT JOIN {faq_weights} w ON w.tid = tn.tid AND n.nid = w.nid WHERE n.type='faq' AND n.status = 1 AND tn.tid = '".$term->tid."' ORDER BY weight, n.sticky DESC, n.created DESC", "n", "nid");
  	
    //$result = db_query(db_rewrite_sql("SELECT n.nid, if((w.weight IS NULL), %d, w.weight) as weight, n.sticky, n.created FROM {node} n INNER JOIN {term_node} tn ON (n.nid = tn.nid AND n.vid = tn.vid) LEFT JOIN {faq_weights} w ON w.tid = tn.tid AND n.nid = w.nid WHERE n.type='faq' AND n.status = 1 AND tn.tid = '%d' ORDER BY weight, n.sticky DESC, n.created DESC", "n", "nid"), $default_weight, $term->tid);
  }
  $result = pager_query($sql, 10, $element=2, $count_sql); 

Then in .tpl files
you should add
<?php echo theme_pager(array(), 2, 2);?>