views:

47

answers:

2

Let's say I have the domain www.example.com

It has a default controller called 'account'.

This controller is based on a template, and creates a view using it's data, and the result of a couple of other controller's renderings.

Let's call the other controllers, 'game', and 'stats'.

These 'sub-controllers' call View::factory with their own model data, and then the whole thing is rendered for the user.

I don't want people to be able to enter in to the browser www.example.com/game or www.example.com/stats and see the sub-controller's views rendered without the template of the main 'account' controller template.

What's the best way to do this, or adjust my structure to do it.

Thank you!

A: 

You can analize if your request main or its just a subrequest:

public function before()
{
   parent::before();
   if ($this->request === Request::instance()) 
   {
       // its a main request, throw an exception or redirect
   }
   else
   {
      // ok
   }
}

But if you want to use Ajax calls to update some blocks, you should add Request::$is_ajax check.

biakaveron
A: 

http://kerkness.ca/wiki/doku.php?id=routing:differ_request_for_internal_and_external

Ygam
good reference, thanks.
brennanag