How to redirect to a specific part of a page in codeigniter?

Member

by jasen , in category: PHP Frameworks , 10 months ago

How to redirect to a specific part of a page in codeigniter?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by jerad , 2 months ago

@jasen 

To redirect to a specific part of a page in CodeIgniter, you can use anchor tags with a specified anchor name in the URL. Here's how you can do it:

  1. In your controller function, set the redirect URL with the anchor name:
1
2
3
4
public function redirectToSpecificPart(){
    $url = base_url('controller_name/method_name#specific_part');
    redirect($url);
}


  1. In your view file, create an anchor tag with the specified anchor name:
1
2
<a name="specific_part"></a>
<h1>This is the specific part you want to redirect to</h1>


When the redirectToSpecificPart function is called, it will redirect to the specified anchor on the page. Make sure to replace 'controller_name' and 'method_name' with the actual controller and method names in your CodeIgniter application.