2

How do I load Ajax pager? My code in custom module

function organization_news_page(){
if(menu_get_object()){
$node = menu_get_object();
$query = db_select('node', 'n')
    ->fields('n', array('nid', 'uid', 'type'))
    ->condition('n.status', NODE_PUBLISHED)
    ->condition('n.type', 'news', '=')
    ->extend('PagerDefault')
    ->limit(10)
    ->orderBy('n.created', 'DESC');
$result = $query->execute();
$output = '';
    foreach($result as $value){
      if($value->uid == $node->uid){
        $node_news = node_load($value->nid);
        $image = theme('image_style', array('style_name' => '165x103', 'path' => $node_news->field_image['und'][0]['uri']));
        $body = render(field_view_field('node', $node_news, 'body', array('label' => 'hidden', 'type' => 'text_summary_or_trimmed', 'settings' => array('trim_length' => 200))));
        $output .= '<div class="news-organization-page"><span class="image-news-page">'.$image.'</span>';
        $output .= '<span class="date-created-news-page">'.format_date($node_news->created, 'custom', 'j.m.Y').'</span>';
        $output .= '<span class="title-news-page">'.$node_news->title.'</span>';
        $output .= $body;
        $output .= l('подробнее...', 'node/'.$node_news->nid, array('attributes' => array('class' => array('read-more-link'))));
        $output .= '</div>';
    }
  }
  $output .= theme('pager', array('element' => 1, 'quantity' => 9));
  return $output;

 }
}
3
  • Views has ajax built in. Is the pager being generated by Views? If so, just toggle ajax on in the Views settings. Commented Oct 31, 2013 at 20:11
  • 2
    I do not use Views Commented Oct 31, 2013 at 20:13
  • Facing same challenge here. Anyone???? Commented Apr 11, 2018 at 11:57

0

Your Answer

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

Browse other questions tagged or ask your own question.