0

我必须在分页页面的中心显示一个块就像页面有 10 个项目的列表

我们如何在页面上将它分成两部分,以便在每 5 个项目之后 - 我可以显示一个启用 Javascript 的自定义块,以便在那里有我们的自定义脚本

寻呼机逻辑

   //logic of count

$model              = &$this->getModel();
$modelCategoryList  = &$this->getModel( 'list' );
$newslistTotal = $modelCategoryList->get_news_list_total();
$page = (isset($_REQUEST['page'])!="")? $_REQUEST['page'] : 1;
$records_per_page=10;               
$offset = ($page-1) * $records_per_page;

   //display count on the pager page based on logic

      $newslist = $modelCategoryList->get_news_list($offset,$records_per_page);         
    $this->assignRef('newslist'  , $newslist);

查看表格

if(count($this->newslist) >0){

foreach($this->newslist as $newslist)
{
    $list .='<h2><strong>'.$newslist->make.' - '.$newslist->model.'</strong></h2>
    <p>'.$newslist->n_month.' - '.$newslist->year.'</p>
    <p>'.$newslist->list_description.'</p>
    <p></p><hr/>';
        }
 }else{
$list='<div>No Listings.</div>';
  }
   ?>

      <?php echo $list?> 

通过上述逻辑 - 项目在页面上列出,并进一步使用寻呼机逻辑给出页码。

如何实现点赞 ,让所有有 10 个列表的页面都能在点赞中回显

      <?php echo $list1?> (of first 5 entries)

    <custom script> ........  </custom script>

      <?php echo $list2?> (of balance 5 entries)

编辑

4

1 回答 1

0

您可以为此使用模数。

if ($i % 5 === 0) {
   // custom code
}

每次取模结果为 0(每 5 行)时,它都会显示自定义代码。

于 2013-09-16T10:21:04.000 回答