我对一些凌乱的代码没有什么问题,我认为它可以更好,我使用分页类来显示页面,唯一的问题是我想设置不同的样式?现在我的控制器中有一些功能?
public function products
{
$config["per_page"] = 4;
$config["uri_segment"] = 2;
$config['cur_tag_open'] = '<li><span class="page active">';
$config['cur_tag_close'] = '</span></li>';
$config['num_tag_open'] = '<li class="page gradient">';
$config['num_tag_close'] = '</li>';
$config['prev_link'] = '< prev';
$config['prev_tag_open'] = ' <li class="page gradient">';
$config['prev_tag_close'] = '</li>';
$config['next_link'] = 'next >';
$config['next_tag_open'] = '<li class="page gradient">';
$config['next_tag_close'] = '</li>'
}
和其他再次相同
public function milks
{
$config["per_page"] = 4;
$config["uri_segment"] = 2;
$config['cur_tag_open'] = '<li><span class="page active">';
$config['cur_tag_close'] = '</span></li>';
$config['num_tag_open'] = '<li class="page gradient">';
$config['num_tag_close'] = '</li>';
$config['prev_link'] = '< prev';
$config['prev_tag_open'] = ' <li class="page gradient">';
$config['prev_tag_close'] = '</li>';
$config['next_link'] = 'next >';
$config['next_tag_open'] = '<li class="page gradient">';
$config['next_tag_close'] = '</li>'
}
你看有没有一样的?但是我使用它两次,每次我有分页我必须把配置放在那个函数中,是否有可能以全局方式设置它
function __construct()
{
$config["per_page"] = 4;
$config["uri_segment"] = 2;
$config['cur_tag_open'] = '<li><span class="page active">';
$config['cur_tag_close'] = '</span></li>';
$config['num_tag_open'] = '<li class="page gradient">';
$config['num_tag_close'] = '</li>';
$config['prev_link'] = '< prev';
$config['prev_tag_open'] = ' <li class="page gradient">';
$config['prev_tag_close'] = '</li>';
$config['next_link'] = 'next >';
$config['next_tag_open'] = '<li class="page gradient">';
$config['next_tag_close'] = '</li>';
}
我在我的应用程序中使用的所有其他分页都使用相同的样式,而不是逐个功能地重复它?
问候