php - CakePHP: Get model instance by url string -


i have cakephp website , navigaton links stored in database. want navigation entries call custom function return additional, dynamic data link: want add count of articles link "vacancies". call function on model return total count. link rendered on every page.

so need appropriate models instance, not current request, request url points to.

so have url "/en/vacancies". can controller name by:

 $urlinfo = router::parse("/en/vacancies");  $controllername = $urlinfo['controller']; 

what reliable way that?

any other solutions problem welcome.

assuming have method gather navigation link data in model.

app::import('controller', $controllername); $controller = new $controllername;  $controller->loadmodel('yourmodel'); $yourmodel = $controller->yourmodel;  $yourdata = $yourmodel->your_method(); 

there variety of other ways this. but, without knowing more you're going calling function can't provide anymore suggestions.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -