Extending View? |
Hello! I'm trying to extend dashboard.php view with layout.php view. Layout.php is one level up compared to dashboard.php.
I tried "../layout.php" "Views/..path../layout.php" but nothing seems to work. Any suggestion on how to solve this issue? Edit... I found out that this is working... "themes\default\layout". Any other solutions whit which I would avoid using the name of the theme (so in this case - theme with name "default")?
The way I've handled this is to create a new instance of the renderer service, giving it the path to my themes folder:
PHP Code: $path = ROOTPATH ."themes/{$this->theme}"; Passing false as the last argument gives you a non-shared instance. Now, when you use things like $this->extend(), or $this->include() within your views, it will always find it within your theme directory. In the example I linked to, it supports multiple themes within the Themes directory. If you need to get a view from the normal path anywhere, you can still use echo view('...'), which uses the main, shared, instance of the View library that points to the default location.
Killishan thank you very much! It works This is the code I wrote based on your suggestion.
PHP Code: $path = APPPATH . 'views/themes/default/'; // {$this->theme} So now I can in views files use only <?= $this->extend('layout') ?> for extending the view. |
Welcome Guest, Not a member yet? Register Sign In |