drupal 7 - How to use Ajax pager in Drupal7 -
i want use ajax_pager in block. i've installed libraries api , ajax pager api (as described on ap api page). it's still not working. when use 'pager' instead of 'ajax_pager' works. i'm doing wrong?
<?php function latest_news_block_info() { $blocks['latest_news_block'] = array( // info: name of block. 'info' => t('latest news'), ); return $blocks; } function latest_news_block_view($delta = '') { // $delta parameter tells block being requested. switch ($delta) { case 'latest_news_block': // create block content here $block['subject'] = t('last news'); $query = new entityfieldquery(); //change news name of content type $entities = $query->entitycondition('entity_type', 'node') ->pager(5, 0) ->entitycondition('bundle', 'news') ->propertyorderby("created", "desc") ->execute(); $content = ""; foreach($entities['node'] $obj) { $node = node_load($obj->nid); $content .= "<img src='" .file_create_url($node->field_image['und'][0]['uri']) . "' width='200px' height='200px'>" . l($node->title, "node/" . $node->nid) . truncate_utf8($node->body['und'][0]['value'], 200, true, true) . '<br><hr>'; $block['content'] = $content; } break; } $pager = theme('ajax_pager', array('parameters' => array('selector' => 'block-system-main'))); $block['content'] .= $pager; return $block; }
Comments
Post a Comment