猿问

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

我想将我的页脚链接到其他页面的特定部分,但我不知道如何在 CodeIgniter 中执行此操作。我知道在本机 php 中我们必须做这样的事情 <h2>Nosotros</h2>

 <ul>

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


在另一个班级,我们有这个


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

}

}

?>


弑天下
浏览 92回答 2
2回答

呼如林

您可以为特定页脚制作路线//inside config/routes.php$route['footer'] = 'controller/method_name';//controllerfunction method_name(){&nbsp;$this->load->view('includes/footer');}//view&nbsp;<a href="<?php echo base_url('auth/logout'); ?>">QuienesSomos</a>

白衣染霜花

将以下代码放在您的nosotros视图文件中(nosotros.php 或您要链接的其他文件)<div&nbsp;class="present"&nbsp;id="QuienesSomos">和以下代码在您的footer视图文件 (footer.php)<a&nbsp;href="nosotros/#QuienesSomos">&nbsp;¿Quiénes&nbsp;Somos?</a>nosotros这是(其他)页面的控制器路径另外,请查看 Views 文档。
随时随地看视频慕课网APP
我要回答