phpcodeignitertabsanchorpoint

php CodeIgniter-3.1.3 Tab paging and Anchor point


I have a tab, and I access them "news#p1, news#p2, news#p3".But when I paging today, my url like this "http://local.test.com/home/news#p1/2".

controller

public function news($id)
{   
    if ($id) {
        $this_page=$id;
        var_dump($this_page);       
    }

    $page = (int)$this->uri->segment(3); 
    var_dump($page);
    ...
 }

This is my paging html.

<ul class="pagination">
<li class="active"><a>1</a></li>
<li><a href="http://local.test.com/home/news#p1/2" data-ci-pagination-page="2">2</a></li>
<li><a href="http://local.test.com/home/news#p1/3" data-ci-pagination-page="3">3</a></li>
<li><a href="http://local.test.com/home/news#p1/2" data-ci-pagination-page="2" rel="next">»</a></li>
<li><a href="http://local.test.com/home/news#p1/5" data-ci-pagination-page="5">尾页</a></li>
</ul>

But I var_dump($this_page), It is null. When I remove anchor point, It can jump. I don't know why It can't jump, when add anchor point. Hope that the professional to help solve.Thanks!


Solution

  • URL part after # can't accessible through PHP. You can use javascript window.location.hash for getting it.