【问题标题】:How to open a view inside a view with CodeIgniter 4?如何使用 CodeIgniter 4 在视图中打开视图?
【发布时间】:2021-01-12 07:10:48
【问题描述】:

我是 CodeIgniter 4 的新手。在 CodeIgniter 3 中,我们可以在另一个视图中使用一个视图,如下所示:

<head>
      <?php this->load->view("containers/head"); ?>
</head>

但同样不适用于 CodeIgniter 4,我找不到它。有什么建议吗?

祝你有美好的一天!

【问题讨论】:

    标签: codeigniter-4


    【解决方案1】:

    好的,对于那些可能会搜索这个的人,我使用了这个并且它有效。

    <head>
          <?php echo view("containers/head"); ?>
    </head>
    

    【讨论】:

      【解决方案2】:

      我建议您阅读文档。 View Layouts in CI4

      我的视图布局模板layout.php

      [...]
      <head>
          <?= $this->renderSection('head')?>
      </head>
      [...]
      

      我的看法

      <?= $this->extend('layout') ?>
      <?= $this->section('head') ?>
          <!-- Code in block <head> -->
      <?= $this->endSection('') ?>
      

      也可能有帮助:View Parser in CI4

      【讨论】:

        猜你喜欢
        • 2015-02-06
        • 1970-01-01
        • 2022-01-25
        • 1970-01-01
        • 1970-01-01
        • 2021-01-10
        • 1970-01-01
        • 1970-01-01
        • 2019-01-19
        相关资源
        最近更新 更多