codeigniter 分页首页 URL

发布于 2024-12-29 06:16:32 字数 881 浏览 1 评论 0原文

我知道他们有一些关于 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/

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:

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

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

滥情空心 2025-01-05 06:16:32

想象一下您的 base_url 是:

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

因此,更改如下代码以获得您想要的第一个 URL:

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

现在第一页链接应该是:

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

Imagine your base_url is :

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

So, change the code like below to have the first URL as you wish :

$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

慈悲佛祖 2025-01-05 06:16:32

发生这种情况是因为您将“page/”参数添加到分页基本 url

只需更改分页配置即可。设置如下:

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

这有效,第一页的分页链接将为 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:

$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/

遗心遗梦遗幸福 2025-01-05 06:16:32

我最终得到了带有 /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.

镜花水月 2025-01-05 06:16:32

使用以下代码:$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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文