CodeIgniter Forums
Parent Page Link Not Working Correct. - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Parent Page Link Not Working Correct. (/showthread.php?tid=64568)



Parent Page Link Not Working Correct. - wolfgang1983 - 03-05-2016

On my file manager I am trying to create a parent button link which will go back to previous page.

How ever if i am in a sub folder and lets say on page 3 of pagination my parent button will only display the per page query like so


Code:
http://localhost/project-2-upload/index.php?c=filemanager&per_page=6


It should display like


Code:
http://localhost/project-2-upload/index.php?c=filemanager&image_directory=Hello&per_page=6


I can echo $this->input->get('image_directory') this fine and gets the correct query string.

I am not sure what is wrong with code below any suggestions on improvment / examples and why it might not be working


PHP Code:
$parent_url ''            

//$thined_image_directory = substr($this->input->get('image_directory'), 0, strrpos($this->input->get('image_directory'),'/'));

if (null !==($this->input->get('per_page'))) {
    $back_page_no $this->input->get('per_page') - $files_limit;

    $parent_url '&per_page=' $back_page_no;
}

if (
null !==($this->input->get('image_directory'))) {
    $pos strrpos($this->input->get('image_directory'), '/');

    if ($pos) {
        $parent_url '&image_directory=' urldecode(substr($this->input->get('image_directory'), 0$pos));
    }
}

$data['parent'] = site_url('c=filemanager')  $parent_url



RE: Parent Page Link Not Working Correct. - PaulD - 03-05-2016

Hi,

'strrpos' returns FALSE if your search term is not found, perhaps your directory name does not have a slash in it.

Paul.

PS Just out of curiosity, why do you do this?
PHP Code:
if (null !==($this->input->get('per_page'))) { 

And not just this...
PHP Code:
if ($this->input->get('per_page')) { 



RE: Parent Page Link Not Working Correct. - InsiteFX - 03-05-2016

If you just want to go back to the beginning with a parent button you can use something like this.

PHP Code:
$_SESSION['org_referer'] = $_SERVER['HTTP_REFERER']; 

I would convert it to CI.


RE: Parent Page Link Not Working Correct. - wolfgang1983 - 03-05-2016

(03-05-2016, 03:45 PM)InsiteFX Wrote: If you just want to go back to the beginning with a parent button you can use something like this.

PHP Code:
$_SESSION['org_referer'] = $_SERVER['HTTP_REFERER']; 

I would convert it to CI.

I tried that not do what I am after.

The code below now works fine with out adding the pagination query


PHP Code:
$parent_url ''

$input_get_directory $this->input->get('image_directory');            

if (isset($input_get_directory)) {
    $pos strrpos($input_get_directory'/');
    if ($pos) {
        $parent_url .= '&image_directory=' urldecode(substr($input_get_directory0$pos));
    }
}

$data['parent'] = site_url('c=filemanager')  $parent_url


But when I add the code below: It will block my image directory get query from work.

PHP Code:
if ($this->input->get('per_page')) {
 
  $backpagecount $this->input->get('per_page') - 6;
 
  $parent_url .= '&per_page=' $backpagecount;

Like

PHP Code:
$parent_url ''

$input_get_directory $this->input->get('image_directory');            

if (isset(
$input_get_directory)) {
    
$pos strrpos($input_get_directory'/');
    if (
$pos) {
        
$parent_url .= '&image_directory=' urldecode(substr($input_get_directory0$pos));
    }
}

if (
$this->input->get('per_page')) {
 
  $backpagecount $this->input->get('per_page') - 6;
 
  $parent_url .= '&per_page=' $backpagecount;
}

$data['parent'] = site_url('c=filemanager' $parent_url