php - Checking for View file existance inside language folder in CakePHP -


i've run annoying problem haven't found answers (either in or whole internet).

i trying develop multi-language site, , have been following cakephp's internalization & localization tutorial. trying place language folders inside views folder, redirect user view file according desired language. problem is, piece of code supposed doesn't work in application:

// app controller code. public function beforefilter() {     $locale = configure::read('config.language');     if ($locale && file_exists(views . $locale . ds . $this->viewpath)) {         // e.g. use /app/view/fra/pages/tos.ctp instead of /app/view/pages/tos.ctp         $this->viewpath = $locale . ds . $this->viewpath;     } } 

the error states there's no views constant, indeed true. tutorial says nothing bit lost here. remove second condition if statement , code work, know someday may want add view files same both languages (views images example) , there should no redirect language folders in case, code do.

i know might missing quite obvious since tutorial doesn`t mention nothing it, glad if share help.

i have found dirty solution problem, , i'm still hopeful better solutions show up. anyway, solution:

i've replaced condition:

file_exists(views . $locale . ds . $this->viewpath)) 

for

file_exists(app . ds . 'view' . ds . $locale . ds . $this->viewpath) 

now app finds path correctly.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -