Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load view by name or search for index.php file contained in folder wi… #6152

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions system/core/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -915,6 +915,18 @@ protected function _ci_load($_ci_data)
break;
}

// checks if there is a directory with that name and a contained index.php.
if(!file_exists($_ci_view_file.$_ci_file) && is_dir( str_replace('.php', '/', $_ci_view_file.$_ci_file)))
{
$_ci_file = str_replace('.php', '/', $_ci_view_file.$_ci_file).'index.php';
if(file_exists($_ci_file))
{
$_ci_path = $_ci_file;
$file_exists = TRUE;
break;
}
}

if ( ! $cascade)
{
break;
Expand Down
9 changes: 9 additions & 0 deletions user_guide_src/source/general/views.rst
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,15 @@ directory name loading the view. Example::

$this->load->view('directory_name/file_name');

Or just passing the directory name it will fetch a file from index.
Example:

$this->load->view('directory_name');

if you do not have a file with that name, it is the equivalent of:

$this->load->view('directory_name/index');

Adding Dynamic Data to the View
===============================

Expand Down