Welcome Guest, Not a member yet? Register   Sign In
Clarification how to use view_cell, layouts or views
#1
Question 

Hi everybody,

I've been struggling on how or when to use which type of view. I understand the differences and I think I know how to use them but it is unclear to me what the benefits are.

Let's say I have the structure as follows:
-------------------
|    Navbar      |
-------------------
|    Main         |
-------------------
|    Footer       |
-------------------

What is the difference between using those structures?

1: 3 php files
echo view(navbar.php, $data1)
echo view(main.php, $data2)
echo view(footer.php, $data1)

2: 1 main.php + view_cells
main.php:
[...]
<body>
    <?= view_cell('App\Libraries\ViewComponents::getNavbar', '$data1') ?>
    <?= view_cell('App\Libraries\ViewComponents::getMain', '$data2') ?>
    <?= view_cell('App\Libraries\ViewComponents::getFooter', '$data1') ?>
</body>

3: Sections
main.php
[...]
<body>
    <?= this->renderSection('page_body') ?>
    <?= this->renderSection('page_body') ?>
    <?= this->renderSection('page_footer') ?>
</body>
Reply


Messages In This Thread
Clarification how to use view_cell, layouts or views - by elserra - 04-12-2020, 10:42 PM



Theme © iAndrew 2016 - Forum software by © MyBB