• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Parent Page Link Not Working Correct.

#1
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
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply

#2
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')) { 
Reply

#3
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.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#4
(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
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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