CodeIgniter Forums
Display a partial view based on the current view name - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=11)
+--- Thread: Display a partial view based on the current view name (/showthread.php?tid=82185)



Display a partial view based on the current view name - b126 - 06-22-2022

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!


RE: Display a partial view based on the current view name - kenjis - 06-22-2022

See https://codeigniter4.github.io/CodeIgniter4/outgoing/views.html#adding-dynamic-data-to-the-view


RE: Display a partial view based on the current view name - b126 - 06-24-2022

(06-22-2022, 04:16 PM)kenjis Wrote: See https://codeigniter4.github.io/CodeIgniter4/outgoing/views.html#adding-dynamic-data-to-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


RE: Display a partial view based on the current view name - kenjis - 06-24-2022

(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.


RE: Display a partial view based on the current view name - ikesela - 06-24-2022

pass parameter (view name) to view