简体   繁体   中英

How to link to a specific part of the page with CodeIgniter

I want to link my footer to a specific part of other page but i don't know how to do it in CodeIgniter. I know in native php we have to do something like this <h2>Nosotros</h2> <ul> <li><a href="nosotros.php#QuienesSomos"> ¿Quiénes Somos?</a></li>

And in the other class we have this

<div class="present" id="QuienesSomos">

I understand that, my question is, how do i implement that to a controller? My controller is this

defined('BASEPATH') OR exit('No direct script access allowed');
class nosotros_controller extends CI_Controller{
function __construct(){
    parent::__construct();
}
function index(){
    $datav["titulopagina"] ="Nosotros";
    $this->load->view('includes/header',$datav);
    $this->load->view('inicio/banner');
    $this->load->view('nosotros/nosotros');
    $this->load->view('includes/footer');
}
}
?>

Put following code In your nosotros view file (nosotros.php or other file that you want to link)

<div class="present" id="QuienesSomos">

and following code In your footer view file (footer.php)

<a href="nosotros/#QuienesSomos"> ¿Quiénes Somos?</a>

nosotros here is the controler path of the (other) page

Also, take a look at Views documentation .

you can make route for specific footer

//inside config/routes.php
$route['footer'] = 'controller/method_name';
//controller
function method_name(){
 $this->load->view('includes/footer');
}
//view 
<a href="<?php echo base_url('auth/logout'); ?>">QuienesSomos</a>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM