2013-02-20 1 views
0

필자는 경로 배열을 지정하면 각 경로에서 파일을 찾은 다음 하나의 경로 배열을 지정하면 파일 경로 만 찾습니다. 왜 처음부터 불고 있습니까?

내 질문

, 당신은 그것을 같은 경로의 배열을 줄 때입니다 :

$array = array(
    'template_view_paths' => array(
     'path_name' => some/path/ 
     'path_name_two' => some/path/two/ 
    ) 
) 

some/path/에서 파일을 찾을 보이지만 some/path/two/에 계속 유지하고 파일이 존재하지 않기 때문에 밖으로 괴물 . 어떤 경로에서 파일을 찾으면 다른 경로를 찾지 못하게하려면 무엇을 변경해야합니까?

코드는 - 재 고려하지

public function render_view($template_name){ 
    if(!isset($this->_options['template_view_path'])){ 
     throw new AisisCore_Template_TemplateException('Not view path was set.'); 
    } 

    if(is_array($this->_options['template_view_path'])){ 
     foreach($this->_options['template_view_path'] as $template=>$path){ 
      require_once($path . $template_name . '.phtml'); 
     } 
    }else{ 
     if(!file_exists($this->_options['template_view_path'] . $template_name . '.phtml')){ 
      throw new AisisCore_Template_TemplateException('Could not find: ' . $template_name . '.phtml at ' . $path); 
     } 

     require_once ($this->_options['template_view_path'] . $template_name . '.phtml'); 
    } 
} 

참고 :부분에 초점이 if(is_array()){} 루프입니다.

답변

0

는해야하지 :

if(is_array($this->_options['template_view_path'])){ 
    foreach($templates as $template=>$path){ 
     require_once($path . $template_name . '.phtml'); 
    } 
}else{ 

BE : 당신은 결코 실제로 $this->_options['template_view_path'] 반복하지있어

if(is_array($this->_options['template_view_path'])){ 
    foreach($this->_options['template_view_path'] as $template=>$path){ 
     if (file_exists($filename = $path . $template_name . '.phtml')) { 
      require_once($filename); 
      return; 
     } 
    } 

    throw new AisisCore_Template_TemplateException('Could not find: ' . $template_name . '.phtml in any paths'); 
}else{ 

.

+0

귀하의 권리 나는 작은 실수를 저질 렀습니다. 나는 고칠 수있다. 나는 또한 당신이 그걸 확인함으로써 한 것을 봅니다. 수표가 지저분하지만. 그러나 그것은 작동하고 정리 될 것입니다. 감사합니다. – TheWebs

+0

@ TheWebs Updated. –

+0

나는 그것을 보았다, 고마워. 3 분 안에 불만족 – TheWebs

관련 문제