如何使用codeigniter在分页中添加“div”

时间:2014-07-28 06:12:12

标签: php css codeigniter pagination

我有一个分页代码,它以表格格式显示结果,这是我在代码中定义的,但问题是我想要更改代码,以便我可以编辑结果并按术语格式化div声明。 Pliz协助我确定在所有三个字段中包括div语句的位置(即,课程,等级,位置),这意味着,例如,我希望我的课程可能是一个名为mydiv n的div,当谈到我的观点时,我希望它像这样(<div class="mydiv">course</div>)。我只上传了下面的分页页面的最后一部分。我还在视图中包含了调用分页结果的位置。显示我在视图中的位置或简单的术语,告诉我如何在视图中单独调用每个项目。

分页控制器

// generate pagination
    $this->load->library('pagination');

    $config['base_url'] = site_url('pagination/index/').'/'.$keys.'/';
    $config['per_page'] = $this->limit;
    $config['uri_segment'] = $uri_segment;
    $this->pagination->initialize($config);
    $data['pagination'] = $this->pagination->create_links();

    // generate table data      
    $this->load->library('table');
    $this->table->set_empty("&nbsp;");

    $heading = array('No','Course', 'Grade', 'Location');               

    $this->table->set_heading($heading);
    $i = 0 + $offset;
    foreach ($parents as $parent){          
        $this->table->add_row(++$i, $parent->course, $parent->grade, $parent->location);
    }
    $data['table'] = $this->table->generate();      

    // load view
    $this->load->view('paginationview', $data);

查看

<?php echo $pagination; ?>

2 个答案:

答案 0 :(得分:0)

尝试将此添加到配置文件中:

        $config['full_tag_open'] = "<div id='pagination'>";
        $config['full_tag_close'] = "</div>";

答案 1 :(得分:0)

你可以在控制器中使用它

 /*for pagination*/
        $config = array();
    $config["base_url"] = base_url() . "index.php/dashboard/roomInfo";
    $config["total_rows"] =     $this->dashboard_model->record_count_all_room_registration();
    $config["per_page"] = 5;
    $this->pagination->initialize($config);
    $page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;

    $config["num_links"] = $config["total_rows"] / $config["per_page"];
    $config['full_tag_open'] = '<ul class="tsc_pagination tsc_paginationA tsc_paginationA01">';
    $config['full_tag_close'] = '</ul>';
    $config['prev_link'] = 'First';
    $config['prev_tag_open'] = '<li>';
    $config['prev_tag_close'] = '</li>';
    $config['next_link'] = 'Next';
    $config['next_tag_open'] = '<li>';
    $config['next_tag_close'] = '</li>';
    $config['cur_tag_open'] = '<li class="current"><a href="#">';
    $config['cur_tag_close'] = '</a></li>';
    $config['num_tag_open'] = '<li>';
    $config['num_tag_close'] = '</li>';
    $config['first_tag_open'] = '<li>';
    $config['first_tag_close'] = '</li>';
    $config['last_tag_open'] = '<li>';
    $config['last_tag_close'] = '</li>';
    $config['first_link'] = '&lt;&lt;';
    $config['last_link'] = '&gt;&gt;';
    $this->pagination->initialize($config);

   $config['display_pages'] = FALSE;
         $data["links"] = $this->pagination->create_links();
          /* pagination ends here */

并且只是为了这个

    <div class="pagination">
        <?php echo $links; ?>
    </div>

然后css就在这里

           /*for pagination*/
     ul.tsc_pagination { margin:4px 0; padding:0px; overflow:hidden; font:12px 'Tahoma'; list-style-type:none; }
      ul.tsc_pagination li { float:left; margin:0px; padding:0px; margin-left:5px; }

    ul.tsc_pagination li a { color:black; display:block; text-decoration:none; padding:7px 10px 7px 10px; }


     ul.tsc_paginationA li a { color:#FFFFFF; border-radius:3px; -moz-border-radius:3px; -webkit-border-radius:3px; }

      ul.tsc_paginationA01 li a { color:#474747; border:solid 1px #B6B6B6; padding:6px 9px 6px 9px; background:#E6E6E6; background:-moz-linear-gradient(top, #FFFFFF 1px, #F3F3F3 1px, #E6E6E6); background:-webkit-gradient(linear, 0 0, 0 100%, color-stop(0.02, #FFFFFF), color-stop(0.02, #F3F3F3), color-stop(1, #E6E6E6)); }
   ul.tsc_paginationA01 li:hover a,
     ul.tsc_paginationA01 li.current a { background:#FFFFFF; }
    .pagination
{
margin: 0px; color: #3399ff; width:100%;
    }
  /*pagination css ends up*/