Hi Andy,

great, I suspected this could be done both ways, but really hadn't a
clue about how.

Now thank to your suggestions I solved it with Media Views, see
http://book.cakephp.org/2.0/en/views/media-view.html
Quite sure that adding a mod_rewrite rule is cleaner and more
efficient, I might try that later.

Here below the full details of the -still elegant- Cake 2.0 solution.

Add to Config/routes.php

Router::connect(
  '/app/img/*',
   array(
    'controller' => 'workarounds',
    'action' => 'showmedia',
    'file' => 'whatever'
   )
);

and create a new controller at Controller/WorkaroundsController.php

<?php

class WorkaroundsController extends AppController {

  /**
   * show image from correct path
   * @param string $file
   */
  function showmedia($file) {
    $this->viewClass = 'Media';

    $params = array(
        'id' => $file.'.'.$this->request->params['ext'],
        'name' => $file,
        'download' => false,
        'extension' => $this->request->params['ext'],
        'path' => 'img'.DS
    );
    $this->set($params);
  }
}

?>

Thank you again.

Best,

Mario


On Jan 3, 6:52 am, AD7six <[email protected]> wrote:

> If you don't simply solve this with mod_rewrite (add a rule ala ^app/
> (.*) $1 to your _webroot_ .htaccess file), just route /img/* to a
> controller action that uses media view.
>
> AD

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to