Codeigniter - 添加“活跃”的CSS类,如何申请一个链接?
问题描述:
我有这样 http://localhost/bestbookfinder.com/viewallbooks/books/pgn/grid/6
Codeigniter - 添加“活跃”的CSS类,如何申请一个链接?
其中一个网址:
bestbookfinder.com:项目名称
viewallbooks:类名
书:功能
PGN:常量参数
电网:视图类型
:分页当前页码
所以现在我想读上面所示的网址以及应用CSS类用下面的代码,但不幸的是我的代码不工作。 我想我错了,当我试图阅读的网址。
请帮我解决这个问题
<?php
if ($this->uri->uri_string() == '/books/pgn/grid')//i think mistake is here
{
echo "".anchor(base_url().'viewallbooks/books/pgn/grid/'.$this->uri->segment(5),' Grid', array('id' => 'gridactive'))."";
}
?>
答
从codeigniter manual - uri_string()
返回具有完整的URI的字符串。所以在你的例子中,这将是"viewallbooks/books/pgn/grid/6"
。
因此"viewallbooks/books/pgn/grid/6" != '/books/pgn/grid'
就做这样的事情:
if ($this->uri->segment(4) == "grid")
{
// do something
}
答
if($this->uri->segment(4) == 'grid'){
//carry on