Is it typical that data is fetched from within templates rather than in controllers? I'm assessing Craft's suitability for my next project, coming from using HMVC in CodeIgniter with a custom CMS.

In CI all requests go via a controller action which is responsible for inspecting request parameters, loading and filtering data and passing that data to a view. Pretty typical MVC.

From what I've seen so far of Craft and plugins developed for it, the requests are typically forwarded directly to Twig templates and those templates are responsible for analysing query strings and request data and fetching data from exposed template variables or built in "entries".

I'm thinking of a use case where data would need to be displayed and filtered by query string and session criteria and it strikes me that the template would be handling too much of this logic and become bloated.

Most of the website I will be developing will get its data in JSON format from a REST API and passing filter criteria from user interaction with forms and UI controls will come up a lot.

My question is, is this a typical and recommended approach to using Craft, or should I be using controllers to handle tasks such as filtering and fetching data and passing it to a view?

Are there any plugins that I could look at for reference that could help me to understand the flow and process?

Thanks

Jamie
From what I've seen so far of Craft and plugins developed for it, the requests are typically forwarded directly to Twig templates and those templates are responsible for analysing query strings and request data and fetching data from exposed template variables or built in "entries".


Not necessarily required.  You can register a custom CP route in your plugin and have a request routed directly to your plugin's controller action.

public function registerCpRoutes()
{
    return array(
        'path' =&gt; array('action' =&gt; 'pluginHandle/controllerAction')
    );
}


And have that controller render a the template directly, passing in whatever variables it needs:

$this-&gt;renderTemplate('pluginHandle/template', array('foo' =&gt; 'bar');