Skip to content

Commit ebff6a6

Browse files
authored
Merge pull request #1341 from bcit-ci/viewpath
Make viewpath configurable in Paths.php. Fixes #1296
2 parents 49b2b79 + a9c3a6f commit ebff6a6

3 files changed

Lines changed: 25 additions & 6 deletions

File tree

application/Config/Paths.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,16 @@ class Paths
7575
* with your host's needs.
7676
*/
7777
public $publicDirectory = 'public';
78+
79+
/*
80+
* ---------------------------------------------------------------
81+
* VIEW DIRECTORY NAME
82+
* ---------------------------------------------------------------
83+
*
84+
* This variable must contain the name of the directory that
85+
* contains the view files used by your application. By
86+
* default this is in `application/Views`. This value
87+
* is used when no value is provided to `Services::renderer()`.
88+
*/
89+
public $viewDirectory = 'application/Views';
7890
}

system/Config/Services.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ public static function parser($viewPath = APPPATH.'Views/', $config = null, bool
482482
*
483483
* @return \CodeIgniter\View\View
484484
*/
485-
public static function renderer($viewPath = APPPATH.'Views/', $config = null, bool $getShared = true)
485+
public static function renderer($viewPath = null, $config = null, bool $getShared = true)
486486
{
487487
if ($getShared)
488488
{
@@ -494,6 +494,13 @@ public static function renderer($viewPath = APPPATH.'Views/', $config = null, bo
494494
$config = new \Config\View();
495495
}
496496

497+
if (is_null($viewPath))
498+
{
499+
$paths = config('Paths');
500+
501+
$viewPath = $paths->viewDirectory;
502+
}
503+
497504
return new \CodeIgniter\View\View($config, $viewPath, self::locator(true), CI_DEBUG, self::logger(true));
498505
}
499506

user_guide_src/source/general/managing_apps.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,19 @@ Renaming the Application Directory
1313

1414
If you would like to rename your application directory you may do so
1515
as long as you open **application/Config/Paths.php** file and set its name using
16-
the ``$application_directory`` variable::
16+
the ``$applicationDirectory`` variable::
1717

18-
$application_directory = 'application';
18+
$applicationDirectory = 'application';
1919

2020
Relocating your Application Directory
2121
=====================================
2222

2323
It is possible to move your application directory to a different
2424
location on your server than your web root. To do so open
2525
your main **index.php** and set a *full server path* in the
26-
``$application_directory`` variable::
26+
``$applicationDirectory`` variable::
2727

28-
$application_directory = '/path/to/your/application';
28+
$applicationDirectory = '/path/to/your/application';
2929

3030
Running Multiple Applications with one CodeIgniter Installation
3131
===============================================================
@@ -58,4 +58,4 @@ example, to select the "foo" application for use you would do this::
5858

5959
.. note:: Each of your applications will need its own **index.php** file
6060
which calls the desired application. The **index.php** file can be named
61-
anything you want.
61+
anything you want.

0 commit comments

Comments
 (0)