Thanks to visit codestin.com
Credit goes to github.com

Skip to content
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
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,9 @@ the header, footer and the example_one.php page (in views/home/). By intention a
public function exampleOne()
{
// load view
require APP . 'views/_templates/header.php';
require APP . 'views/home/example_one.php';
require APP . 'views/_templates/footer.php';
view('views/_templates/header');
view('views/home/example_one');
view('views/_templates/footer');
}
```

Expand All @@ -218,9 +218,9 @@ class SongsController
$amount_of_songs = $Song->getAmountOfSongs();

// load view. within the view files we can echo out $songs and $amount_of_songs easily
require APP . 'views/_templates/header.php';
require APP . 'views/songs/index.php';
require APP . 'views/_templates/footer.php';
view('views/_templates/header');
view('views/songs/index');
view('views/_templates/footer');
}
}
```
Expand Down Expand Up @@ -267,6 +267,10 @@ Please commit into the develop branch (which holds the in-development version),

## Changelog

**September 2021**

- [iamrameffort] ♻️: Refactoring the `view` function and removing the extension from the view files in the controllers.

**August 2016**

- [panique] fix for weird lowercase/uppercase path problem (also big thanks to @snickbit & @ugurozturk for the fix!)
Expand Down
6 changes: 3 additions & 3 deletions application/Controller/ErrorController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ class ErrorController
public function index()
{
// load views
view('_templates/header.php');
view('error/index.php');
view('_templates/footer.php');
view('_templates/header');
view('error/index');
view('_templates/footer');
}
}
18 changes: 9 additions & 9 deletions application/Controller/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ class HomeController
public function index()
{
// load views
view('_templates/header.php');
view('home/index.php');
view('_templates/footer.php');
view('_templates/header');
view('home/index');
view('_templates/footer');

}

Expand All @@ -34,9 +34,9 @@ public function index()
public function exampleOne()
{
// load views
view('_templates/header.php');
view('home/example_one.php');
view('_templates/footer.php');
view('_templates/header');
view('home/example_one');
view('_templates/footer');
}

/**
Expand All @@ -47,8 +47,8 @@ public function exampleOne()
public function exampleTwo()
{
// load views
view('_templates/header.php');
view('home/example_two.php');
view('_templates/footer.php');
view('_templates/header');
view('home/example_two');
view('_templates/footer');
}
}
12 changes: 6 additions & 6 deletions application/Controller/SongsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ public function index()
$amount_of_songs = $Song->getAmountOfSongs();

// load views. within the views we can echo out $songs and $amount_of_songs easily
view('_templates/header.php');
view('songs/index.php', ["songs" => $songs]);
view('_templates/footer.php');
view('_templates/header');
view('songs/index', ["songs" => $songs]);
view('_templates/footer');
}

/**
Expand Down Expand Up @@ -101,9 +101,9 @@ public function editSong($song_id)
$page->index();
} else {
// load views. within the views we can echo out $song easily
view('_templates/header.php');
view('songs/edit.php', ["song" => $song]);
view('_templates/footer.php');
view('_templates/header');
view('songs/edit', ["song" => $song]);
view('_templates/footer');
}
} else {
// redirect user to songs index page (as we don't have a song_id)
Expand Down
11 changes: 4 additions & 7 deletions application/Core/CoreFunctions.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@

namespace Mini\Controller;

function view($path, $data = [])
function view(string $file, array $data = [])
{
foreach ($data as $k => $v) {
$$k = $v;
}
require APP . "view/{$path}";
extract($data);
require sprintf('%sview/%s.php', APP, $file);
}


function redirect($path) {
header('location: ' . URL . $path);
}
}
18 changes: 18 additions & 0 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.