Tuesday 15 March 2022

Layout In CI

Step 1 :

Make a folder named shared in app/Views

Step 2 : 

Make 3 files named menu.php,footer.php,layout.php

menu.php : will hold menu of website

layout.php : will hold master layout page for your website

footer.php : will hold footer code 

Step 3 :

menu.php code 

<p style="padding:20px;text-align:center;color:white;background-color:darkblue">

        <a>Menu 1</a> |

        <a>Menu 2</a> |

        <a>Menu 3</a>

</p>

footer.php code :

  <p style="padding:20px;text-align:center;color:white;background-color:black">

       Place Footer content here

  </p>


layout.php code :

<!doctype HTML>
<HTML >
<head>
    <title><?php echo $title;?></title>

    <!--

        Place your CSS links here

    -->  
</head>
<body>

    <?= $this->include('shared/menu') ?>

    <?= $this->renderSection('content') ?>

    <?= $this->include('shared/footer') ?> 

    <!--

         Place your JS links here

     -->

</body>
</html>

View Code :

<?PHP
require("pagelib.php");
?>

<?= $this->extend('shared/layout') ?>
<?= $this->section('content') ?>
<h1>View Content</h1>
<p>
    Place your page content here
</p>

<?= $this->endSection() ?>


 Next Topic

No comments:

Post a Comment