Welcome Guest, Not a member yet? Register   Sign In
CI 4 common layout for few modules
#1

(This post was last modified: 06-01-2022, 07:57 AM by SubrataJ.)

I am working on a ci4 project where I have to use modules, I have got everything right but I want to create a common layout for few Modules view files,
here is what I have tried so far 
PHP Code:
<?= view('AdminTemplate/Views/include/_header'); ?>
<?= view
('AdminTemplate/Views/include/_sidebar'); ?>
<?= view
('AdminTemplate/Views/include/_js'); ?>
<?= $this
->renderSection('main'); ?>
<?= view
('AdminTemplate/Views/include/_footer'); ?>

AdminTemplate is a module for template layout only I have mentioned the path for AdminTemplate in Autoload.php, I can access the layout But I am not able to load the view inside it.
but I am getting an Invalid file: AdminTemplate\Views\include\_header.php 
please let me know if there's any better way to do it as I am learning CI4.
Reply
#2

This is how I load it, page is called 'page.php':
Code:
<div class="wrapper"><!-- wrapper -->
     <?= $this->include('Modules\Views\Admin\navigation') ?>
    <?= $this->include('Modules\Views\Admin\sideNavigation') ?>
    <div class="content-wrapper"><!-- /.content-wrapper -->
        <?= view('Modules\Views\Admin\Blocks\_contentHeader') ?>
        <?= $this->renderSection('content') ?>
    </div><!-- /.content-wrapper -->
    <?= $this->include('Modules\Views\Admin\footer') ?>
</div><!-- ./wrapper -->


Then, in the view I use the following code:

Code:
<?= $this->extend('Modules\Views\Admin\page') ?>
<?= $this->section('content') ?>







Reply




Theme © iAndrew 2016 - Forum software by © MyBB