Posts: 2
Threads: 1
Joined: Apr 2017
Reputation:
0
This week I'm starting with a new course about frameworks and CI at SAE Zurich Institute.
Because I'm the teacher, I'm reading the documentation very attentively.
Two things seems to me not to be optimally solved in the tutorials:
- There is no really "Hello World" example
- In the "Static Page"-Example there is a method named "view()" in the CI_Controller Class.
This is very confusing for students who are new in the MVC world, because at the beginning it's very hard to understand the difference between controllers, Models and views (and to call the methods belonging to it)
I guess the reason for "view()" is "view the pages". It's has nothing to do with the "view"-expression coming from the MVC-Model
PLEASE rename this method for didactic reasons with an another word like "show()" or "showPage()". I think thousands of newbies would be grateful for this.
Thank you!
Posts: 1,020
Threads: 15
Joined: Jun 2015
Reputation:
50
Actually the method view() does not "show" anything. The showing action takes place much later after the controller is done executing. This happens without developer intervention.
To be pedantic, show() is a method of the loader class not the controller. So $this->load->view("someview"); is utilizing the "load" property of the controller ($this) to call the loader method "view" which will "include" the file "someview". Views are not classes in the CodeIgniter framework. They are php files that contain html and potentially template language markup. Because they are not classes views have no methods. But they might contain functions and frequently include php code along with the markup.
Defining a controller method called show() or showPage() that makes the call to view() would be a good instructional project for your students.
On the other hand, changing the name would be entertaining mostly because of the s__ storm is would cause due to the broken backward compatibility.
Posts: 2
Threads: 1
Joined: Apr 2017
Reputation:
0
Dear all,
thank you very much for your posts!
I'm teaching web technologies (like PHP OOP) since a long time and I am web developer as well.
I've realized several projects with CI and I really love this framework. I my opinion, the documentation of CI is ten times better than the one of Symfony and a hundred times better than the one of ZEND Framework.
CI is the best choice to explain basic principles in a PHP-framework like routing, MVC-pattern, form helpers, DB interaction, etc. My intention is to make an outstanding thing even better.
So again: The tutorial is for most of new users/learners the first contact with CI, but:
CI has it's own, native, given names (somehow like keywords) for methods. One of this "keyword" ist "view()".
But in the example, the word "view()" is used for a [controller-method] with I can baptize by myself. It has an influence on the routing
The same word "view()" is in the bottom of the same script (!!!), but there it has completely different meaning (!!!), because here it loads a view.
This fact is poison for a newbie, and I do not want anyone to be confused, because I really love CI. I think there's a real, deep need for changing the tutorials on this point!
Maybe this forum is not the best place for this topic, because it's not me that needs help. I have chosen this forum because of the hint "Not sure where else to ask something?"
Best wishes