codeigniter 分页首页 URL
我知道他们有一些关于 codeigniter 分页的问题,但据我所知,它们似乎不相关。
仅供参考,我在 URL 中使用页码,而不是索引(使用配置选项 use_page_numbers),
所以我的问题是第一个链接。
我的第 1 页以外的页面的网址结构是:
http://www.something.com/foo /page/x
一切正常,但是当我将鼠标悬停在第 1 页的链接上时,出现的网址是:
http://www.something.com/foo/page/
现在我知道那是因为我将基本 url 声明为:
$config['base_url'] = $this->uri->slash_segment(1, 'both') . 'page/';
但是是否可以将第 1 页的 URl 设为:
或
http://www.something.com/foo/page/1/
希望这是有道理的有人可以帮忙。如果第三段是空的但没有喜悦,我确实尝试将 base_url 设置为 page/1。
感谢您的阅读
I know their are a few questions on codeigniter pagination but from what I can tell they dont seem to be relevent.
FYI I am using page numbers in my URL, not the index (using config option use_page_numbers)
So my problem is the first link.
My url structure for a page other than page 1 is:
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:
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:
OR
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.
thanks for reading
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
想象一下您的 base_url 是:
因此,更改如下代码以获得您想要的第一个 URL:
现在第一页链接应该是:
http ://example.com/method/page/1
Imagine your base_url is :
So, change the code like below to have the first URL as you wish :
Now the first page link should be:
http://example.com/method/page/1
发生这种情况是因为您将“page/”参数添加到分页基本 url
只需更改分页配置即可。设置如下:
这有效,第一页的分页链接将为 http://www.something.com /foo/
This thing happens because you are adding 'page/' parameter to pagination base url
Just change your configuration for pagination. Set it as below:
This works and the pagination link for the first page will be http://www.something.com/foo/
我最终得到了带有 /foo/ 的 URL,其中没有“page”段。这是使用文档中的常规方法完成的:
http://codeigniter.com/user_guide/libraries/ pagination.html
感谢大家的意见。
I just ended up having the URL with the /foo/ without the 'page' segment in there. This was done using the normal method from the docs:
http://codeigniter.com/user_guide/libraries/pagination.html
Thanks to everyone for your input though.
使用以下代码:
$FullURL =explode('?',$_SERVER['REQUEST_URI']);
$config['first_url'] = base_url() 。 '测试/测试?'.$FullURL[1];
$this->分页->initialize($config);
这将解决您的问题。
Use Following code:
$FullURL = explode('?',$_SERVER['REQUEST_URI']);
$config['first_url'] = base_url() . 'test/testing?'.$FullURL[1];
$this->pagination->initialize($config);
This is will solve your issue.