only one view is viewed.. |
Hi guys, im very new to codeigniter so sorry..
![]() Code: namespace App\Controllers; Im doing the most simple thing - trying to make my static page. Problem is that when i go to /articles/ it only shows the first of the views - in this example header template. In case of deleting first view i get the second one, and /articles/ pages will show 'articles_page' view. What's wrong ?? i have basically no clue.
use
echo view('templates/header'); echo view('pages/articles_page'); echo view('templates/footer');
12-20-2021, 11:28 AM
(This post was last modified: 12-20-2021, 11:30 AM by captain-sensible. Edit Reason: extra )
the basic approach to getting a view rendered with data from a controller is :
Code: $data = [ here i get a date via my own approach and want to pass to view , i get a title so i can pass that to header. the view is called home.php , but i only need to mention "home" for system to find it , as long as its in app/views The best approach i've found so far is to have a html content page with suffix .php that is a whole html page , into which other content is injected; i think similar to Blade. So I have a template called layout.php at the place I want i have : Code: <?= $this->renderSection('content') ?> then i have in various static view this content : Code: //file called about_us.php the only difference between my static pages is the content of blah blah So you need to look into documentation and find layouts
use echo instead of return, because function ends after the first return
reference https://www.codeigniter.com/user_guide/o...views.html PHP Code: namespace App\Controllers; |
Welcome Guest, Not a member yet? Register Sign In |