Controller and pages/views

Permalink
Hi Guys,

I'm still new to concrete 5 and starting to play around with custom scripts and stuff.

For Controllers, is it just a controller per page?

This is what I want to do:

class SomeController extends Controller {
  function view() {
    // goes to view page
  }
  function other_function() {
   // goes to other_function page
  }
}


Right now it seems like it's all going to the same view where you can check for different actions. This isn't a big deal, but it can make a single view file disorganized for larger applications.

Cheers,
-Derek

 
RadiantWeb replied on at Permalink Reply
RadiantWeb
nah..you would just use the controller to house central functions, and then perhaps page types that would call those as needed.

as an example: you might want the header shown in your default view, and then a thin banner on subpages that has some random script that needs called.

so you would create a new page type in your templates dir for subpage, and then call the random script in that template. $controller->randomscript();

one controller, two page types. if I understood you correctly. or to your point, just if/else the daylights out of one view file. lol
matogertel replied on at Permalink Reply
matogertel
Try something like this
class SomeController extends Controller {
  function view() {
    // goes to view page
  }
  function other_function() {
   // do the view code here
   $this->render('/some/other_function');
  }
}


And put a file in single_pages/some/other_function.php
derek replied on at Permalink Reply
Thanks for the help guys.

matogertel: Thanks man! That in deed works.

ChadStrat: I'm not talking about a page type for a theme. More like different pages for message forum. I'm not buildng a forum, just an example:

view post, reply to post, create a post, list posts.

I would want all of those to have seperate php files for the view but all using the same controller.
RadiantWeb replied on at Permalink Reply
RadiantWeb
ahhh. I see. thanks for sharing. this is helpful indeed!