Welcome Guest, Not a member yet? Register   Sign In
Display a partial view based on the current view name
#1

Dear all,
I would like to display a header and menu on every view on my app BUT the logout.
I am using layouts already.

Let's take a quick example from the internet :

PHP Code:
<html>
    <body>
      <?=$this->include("partials/header")?>
      <?=$this->renderSection("content")?>
      <?=$this->include("partials/footer")?>
    <body>
</html> 
Would it be possible to include the "partials/header" on every view BUT not the logout.php one?
How to know which view is running when I am in the template php file.

Thank you!
Reply
#2

See https://codeigniter4.github.io/CodeIgnit...o-the-view
Reply
#3

(This post was last modified: 06-24-2022, 12:04 AM by b126.)

(06-22-2022, 04:16 PM)kenjis Wrote: See https://codeigniter4.github.io/CodeIgnit...o-the-view

I see no direct relation to the question. I don't want to add dynamic data to my views, I (fortunately) know how to do this Smile
I am asking, how, in the view itself and based on its name (not in the controller), I can build a different display (insert or not a header).

Then, is there a way to know the name of the view running in the view itself?

Thank you
Reply
#4

(06-24-2022, 12:04 AM)b126 Wrote: Then, is there a way to know the name of the view running in the view itself?

No.
Reply
#5

(This post was last modified: 06-24-2022, 07:47 AM by ikesela.)

pass parameter (view name) to view
Reply




Theme © iAndrew 2016 - Forum software by © MyBB