[英]How to link to a specific part of the page with 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');
}
}
?>
將以下代碼放入您的nosotros
視圖文件(nosotros.php 或您要鏈接的其他文件)
<div class="present" id="QuienesSomos">
和以下代碼在您的footer
視圖文件(footer.php)中
<a href="nosotros/#QuienesSomos"> ¿Quiénes Somos?</a>
nosotros
這里是(其他)頁面的控制器路徑
另外,請查看視圖文檔。
您可以為特定頁腳制作路線
//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>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.