• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
site_url() attaching suffix more than once with pagination

#1
[eluser]mrmeyers99[/eluser]
In my config file I have: $config['url_suffix'] = ".php";
When I initalize my pagination class I set

$config['base_url'] = site_url('controller/function/'.$param1);

For some reason when I do create_links() It prints out

http://localhost/controller/function/param1.php.php/pagination_start

for all the links. Then when I click on the link the next time it has 3 .phps.

To fix it I created a MY_Config class and changed the site_url() to the following:
Code:
if (is_array($uri))
        {
            $uri = implode('/', $uri);
        }

        if ($uri == '')
        {
            return $this->slash_item('base_url').$this->item('index_page');
        }
        else
        {
            $suffix = ($this->item('url_suffix') == FALSE) ? '' : $this->item('url_suffix');
            $url = $this->slash_item('base_url').$this->slash_item('index_page').preg_replace("|^/*(.+?)/*$|", "\\1", $uri);

            return strripos($url, $suffix) === FALSE ? $url.$suffix :$url;
        }

That fixed this error. This was only a problem with the pagination class, but I would recommend adding the check to see if the suffix is already there.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.