Search code examples
hyperlinkcellcakephp-3.0

Is it possible to link to a class method directly in cakephp 3?


We can generate a block of code using cells without appController interposition. Is it possible to have an html link to cell methods or other methods without appController interposition? Something like this:

$this->Html->link('Show help' , ['controller'=>'Cell::help' , 'action'=>'show']);

Solution

  • No, that's not what view cells are ment for, they are elements on steroids, and as their name suggests, ment to be used in views.

    If you want your app controller to do specific things only for non-AJAX requests, then you could for example do them conditionally

    if (!$this->request->is('ajax')) {
        // ...
    }
    

    See also Cookbook > Request & Response Objects > Checking Request Conditions