2012-08-01 3 views
0

joomla 1.5 구성 요소의 툴바 메뉴에 툴바 추가 버튼을 추가 할 때 문제가 있습니다. 표준 방식으로 맞춤 버튼을 추가해야합니다.이 버튼은 제 메뉴에 추가되었지만 작동하지 않습니다. 버튼에서 매개 변수를 가져 오는 데 도움이 될 함수가 필요합니다. (aaaa).joomla 1.5 구성 요소에 툴바 메뉴 항목 추가.

/* 
ToolBarHelper::custom('aaaa', 'new', 'new', 'Add Article', 'add_article', false); 
*/ 

여기는 작업 매개 변수를 가져 오는 방법 전체 도구 모음 클래스입니다.

// no direct access 
defined('_JEXEC') or die('Restricted access'); 

/** 
* @package Joomla 
* @subpackage Config 
*/ 
class TOOLBAR_video 
{ 

function _DEFAULT() { 
    /* 
    * DEVNOTE: This should make sense by itself now... 
    */ 
    JToolBarHelper::title( JText::_('Video Manager'), 'generic.png'); 

      JToolBarHelper::custom('aaaa', 'new', 'new', 'Add Article', 'add_article', false); 
    JToolBarHelper::help('screen.video'); 


); 
} 
} 

답변

0

그것은 당신이해야 할 모든 사용자 정의

로 사용이 함수를 오버라이드 (override) 할 필요가 있으므로, /의 JS/joomla.javascript.js를 포함하는이 기능은에 위치한 기능 submitbutton 기능 을 덮어 쓰기하는 것입니다 워킹 시작
submitbutton(pressbutton) { 
    submitform(pressbutton); 
} 

나는이 방법으로 글을 쓸 때 enter link description here에 joomla usfull 기사를 발견했다.

function submitbutton(pressbutton) { 
    // Some conditions 
    document.adminForm.task.value=pressbutton; 
    // More conditions 
    submitform(pressbutton); 
    } 

그래서 최종 결과는이

<script> 
      /** 
      * Function is Overwriting native submitbutton() function. 
      * A Custom button relies on javascript from 
      * includes/js/joomla.javascript.js to execute the task indicated by the user: 
      */ 
      function submitbutton(pressbutton) { 
       var url = ''; 
       if (pressbutton == 'add_article') { 
        url = '<?php echo JURI::root(); ?>'+'administrator/index.php?option=com_video&controller=video&action=add_article'; 
        post_to_url(url,{'add_article': 'add_article'}); 
       } 
       if (pressbutton == 'delete_article') { 
        url = '<?php echo JURI::root(); ?>'+'administrator/index.php?option=com_video&controller=articlelisting&action=delete_article'; 
        post_to_url(url,{'add_article': 'add_article'});  
       } 

      } 
      /** 
      * Function is creating form and submitting using given url 
      * @var url string //Joomla admin component constructor path with action 
      * @var params string //it has {'var1': 'value1','var2': 'value2'} notation 
      */ 
      function post_to_url(url, params) { 
       var form = document.createElement('form'); 
       form.action = url; 
       form.method = 'POST'; 

       for (var i in params) { 
        if (params.hasOwnProperty(i)) { 
         var input = document.createElement('input'); 
         input.type = 'hidden'; 
         input.name = i; 
         input.value = params[i]; 
         form.appendChild(input); 
        } 
       } 

       form.submit(); 
      } 
    </script> 
입니다