简体   繁体   English

codeigniter分页第一页网址

[英]codeigniter pagination first page URL

I know their are a few questions on codeigniter pagination but from what I can tell they dont seem to be relevent. 我知道他们是关于codeigniter分页的一些问题,但从我可以说它们似乎并不相关。

FYI I am using page numbers in my URL, not the index (using config option use_page_numbers) 仅供参考我在我的网址中使用页码,而不是索引(使用配置选项use_page_numbers)

So my problem is the first link. 所以我的问题是第一个链接。

My url structure for a page other than page 1 is: 我在第1页以外的页面的网址结构是:

http://www.something.com/foo/page/x http://www.something.com/foo/page/x

That all works fine however when I hover over the link for page 1 the url that comes up is: 一切正常但是当我将鼠标悬停在第1页的链接上时,出现的网址是:

http://www.something.com/foo/page/ http://www.something.com/foo/page/

Now i know thats because ive declared the base url as: 现在我知道那是因为我已经将基本网址声明为:

$config['base_url'] = $this->uri->slash_segment(1, 'both') . 'page/';

But is it possbile to either have the URl for page 1 as: 但是,将第1页的URl作为:

http://www.something.com/foo/ http://www.something.com/foo/

OR 要么

http://www.something.com/foo/page/1/ http://www.something.com/foo/page/1/

Hope that makes sense and someone can help out. 希望这是有道理的,有人可以提供帮助。 I did try setting the base_url to page/1 if the 3rd segment was empty but no joy. 我确实尝试将base_url设置为page / 1,如果第3段是空的但没有欢乐。

thanks for reading 谢谢阅读

Imagine your base_url is : 想象一下你的base_url是:

$config['base_url'] = base_url() . 'method/page/';

So, change the code like below to have the first URL as you wish : 因此,更改下面的代码,以获得您想要的第一个URL:

$config['base_url'] = base_url() . 'method/page/';
$config['first_url'] = '1';
$this->pagination->initialize($config);

Now the first page link should be: 现在第一页链接应该是:

http://example.com/method/page/1 http://example.com/method/page/1

Use Following code: $FullURL = explode('?',$_SERVER['REQUEST_URI']);
$config['first_url'] = base_url() . 'test/testing?'.$FullURL[1];
使用以下代码: $FullURL = explode('?',$_SERVER['REQUEST_URI']);
$config['first_url'] = base_url() . 'test/testing?'.$FullURL[1];
$FullURL = explode('?',$_SERVER['REQUEST_URI']);
$config['first_url'] = base_url() . 'test/testing?'.$FullURL[1];

$this->pagination->initialize($config); $这 - > pagination->初始化($配置);

This is will solve your issue. 这将解决您的问题。

This thing happens because you are adding 'page/' parameter to pagination base url 发生这种情况是因为您要将“page /”参数添加到分页基本URL

Just change your configuration for pagination. 只需更改分页配置即可。 Set it as below: 设置如下:

$pagination['base'] = $this->config->item('base_url');
$config['base_url'] = $pagination['base'].'foo';

This works and the pagination link for the first page will be http://www.something.com/foo/ 这是有效的,第一页的分页链接将是http://www.something.com/foo/

I just ended up having the URL with the /foo/ without the 'page' segment in there. 我刚刚得到了带有/ foo /的URL,而没有'page'段。 This was done using the normal method from the docs: 这是使用文档中的常规方法完成的:

http://codeigniter.com/user_guide/libraries/pagination.html http://codeigniter.com/user_guide/libraries/pagination.html

Thanks to everyone for your input though. 感谢大家的意见。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM