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

Fix passing parameter on index View #863

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
Fix passing parameter on index View
I did a simple example passing a parameter to identify the pagination ID.

I use : 
mysite.com/product/2   (It'sn works, printed 1)

but just works if I using /index/ 

mysite.com/product/index/2 (It's works, printed 2)

My ProductController.php is

https://pastebin.com/aYVEqvjK

With this pull request solved the problem.
  • Loading branch information
Offboard authored Jul 22, 2017
commit d815d5ada99f13aa3fa5f48a57da311254af1e4d
8 changes: 7 additions & 1 deletion application/core/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,13 @@ public function __construct()
// example: if controller would be "car", then this line would translate into: $this->car = new car();
require Config::get('PATH_CONTROLLER') . $this->controller_name . '.php';
$this->controller = new $this->controller_name();

// check View is index and if are passing any value
if ((int) $this->action_name > 0)
{
$this->parameters[] = (int) $this->action_name;
$this->action_name = 'index';
}

// check for method: does such a method exist in the controller ?
if (method_exists($this->controller, $this->action_name)) {
if (!empty($this->parameters)) {
Expand Down