如何使用 CodeIgniter link 到页面的特定部分

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

我想 link 我的页脚到其他页面的特定部分,但我不知道如何在 CodeIgniter 中执行此操作。 我知道在本地 php 我们必须做这样的事情 <h2>Nosotros</h2> <ul> <li><a href="nosotros.php#QuienesSomos"> ¿Quiénes Somos?</a></li>

在另一个 class 中我们有这个

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

我明白了,我的问题是,我如何将其实现到控制器?我的控制器是这个

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');
}
}
?>

将以下代码放入您的 nosotros 查看文件(nosotros.php 或您想要 link 的其他文件)

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

和以下代码在您的 footer 查看文件 (footer.php)

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

nosotros这里是(其他)页面的控制器路径

另外,看看 Views documentation

您可以为特定页脚制作路线

//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>