2017-09-16 2 views
0

3.7으로 업그레이드하기 전에 다음 코드를 사용했지만 "JHtml :: script ('com_members/site.js', array(), true);" 더 이상 site.jsjoomla에서 jhtml :: script가 더 이상 작동하지 않습니다. 3.7

class MembersViewMembersELso extends JViewLegacy 
{ 
     // Overwriting JView display method 
     function display($tpl = null) 
     { 
       // Get data from the model 
       $state = $this->get('State'); 
       $items = $this->get('Items'); 
       $pagination = $this->get('Pagination'); 
       // Check for errors. 
       if (count($errors = $this->get('Errors'))) 
       { 
         JError::raiseError(500, implode('<br />', $errors)); 
         return false; 
       } 
       // Assign data to the view 
       $this->state = $state; 
       $this->items = $items; 
       $this->pagination = $pagination; 
       // get the stylesheet (with automatic lookup, possible template overrides, etc.) 
       JHtml::stylesheet('com_members/site.stylesheet.css', array(), true); 
       // insert js code for onsubmit 
       JHtml::script('com_members/site.js', array(), true); 
       // Display the view 
       parent::display($tpl); 
     } 
} 

답변

0

JHtml::ScriptJHtml::Stylesheet 당신은 하나의 자바 스크립트/CSS 파일을 포함 할 경우에 사용하는 이상적인 방법은 없습니다를로드하지 않습니다. 이 방법에는 불필요한 오버 헤드가 많이 발생하며 둘 다 매우 복잡한 includeRelativeFiles 방법을 사용합니다 (libraries/cms/html/html.php에서 3 가지 방법 모두를 찾을 수 있음).

파일을 포함하기위한 깨끗하고 간단한 방법은 직접입니다 (위의 코드에서 JHtml::ScriptJHtml::Stylesheet을 삭제 물론, 필요합니다) 다음을 수행하는 것입니다

$objDocument = JFactory::getDocument(); 
$objDocument->addStyleSheet(JUri::base() .'com_members/site.stylesheet.css'); 
$objDocument->addScript(JUri::base() .'com_members/site.js'); 
+0

감사합니다을. 나는 당신의 제안을 사용 하겠지만, 왜 JHtml :: Script 문이 갑자기 Joomla 3.7에서 실패하는지 알 수 있습니까? –