Wednesday, March 21, 2012

Using $this->requestAction from shell is breaking the links

Hi, i am using the requestAction feacture to generate the cache of heavy traffic pages, the only problem is that the base param of the urls is /usr/share/php/cake/console/ instead of /, is there any way of solve this? now i am usign a str_replace to change de links but i want a better way to solve this.

Any clue????

Code Example;

<?

App::import('Core', 'Router');
App::import('Sanitize');
config('routes');

class CacheShell extends Shell {

    function main(){

        $url=Router::url(array('controller'=>'posts','action'=>'index'));
        $_url = implode(DS, array_filter(explode('/', $url)));
        $path = WWW_ROOT. 'cache'.DS..DS.$_url.DS.'index.html';
        Configure::write('debug',0);
               
        $html=$this->requestAction($this->params['url'],array('return','bare'=>0,'webroot'=>'/','base'=>'/'));
         $html=str_replace('/usr/share/php/cake/console/','/',$html);
          
        $file = new File($path, true,0777);
        $file->write($html);
    }
}

?>

Cheers!!

--
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
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: