2012-08-01 45 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

它開始沃金所有你需要做的就是要覆蓋功能提交按鈕功能 該功能位於包括/ JS/joomla.javascript.js,所以你應該重寫此功能,用它作爲自定義

submitbutton(pressbutton) { 
    submitform(pressbutton); 
} 

經過一番研究,我找到了joomla usfull文章enter link description here,所以我這樣寫。

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> 
相關問題