Akelos Framework v1 forum archive. This forum is no longer maintained. To report bugs please visit https://github.com/akelos/akelos/issues
    • CommentAuthorkkrzyzak
     

    Hi. I would like render additional template (called submenu) - but only, if it exists for current controller- For instance, dashboard controller hasn't got any subactions, so I don't need submenu with additional actions - but in some controllers I would like to have such menu ;) <%= render :partial=>'submenu'%> works only if I have _submenu.tpl in views directory. How can I check, that this file exists(I hope I don't have to call if(file_exists(AK_VIEWS_CONSTANT.'/views/admin/'.CURRENT_CONTROLLER_CONSTANT.'/_submenu.tpl') ){ //render template }

    •  
      CommentAuthorriffed
     

    Why not?

    • CommentAuthorkkrzyzak
     

    well-this way works, but I can't tell, that looks preety- I'll rather write new helper, with function sth like CheckTemplateExistence(), but I thought, that Akelos has built-in function like this ;)

    •  
      CommentAuthorriffed
     

    http://api.akelos.org/, AkActionView::getFullTemplatePath(). Your line of PHP code works just as well.

    function getFullTemplatePath($template_path, $extension)
    {
        $template_path = substr($template_path,-1*strlen($extension)) == $extension ? $template_path : $template_path.'.'.$extension;
        return substr($template_path,0,strlen(AK_VIEWS_DIR)) == AK_VIEWS_DIR ? $template_path : $this->base_path.DS.$template_path;
    }
    
    function _templateExists($template_path, $extension)
    {
        $file_path = $this->getFullTemplatePath($template_path, $extension);
    
        return !empty($this->_method_names[$file_path]) || file_exists($file_path);
    }