<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://docs.sandbox.joomla.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Norbert73</id>
	<title>Joomla! Documentation - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://docs.sandbox.joomla.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Norbert73"/>
	<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/Special:Contributions/Norbert73"/>
	<updated>2026-08-19T19:16:03Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.0</generator>
	<entry>
		<id>https://docs.sandbox.joomla.org/index.php?title=J1.5:How_to_create_a_custom_button&amp;diff=10558</id>
		<title>J1.5:How to create a custom button</title>
		<link rel="alternate" type="text/html" href="https://docs.sandbox.joomla.org/index.php?title=J1.5:How_to_create_a_custom_button&amp;diff=10558"/>
		<updated>2008-09-06T20:32:40Z</updated>

		<summary type="html">&lt;p&gt;Norbert73: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{cookiejar}}&lt;br /&gt;
{{incomplete}}&lt;br /&gt;
[[Category:Development]]&lt;br /&gt;
&lt;br /&gt;
The code below is used for adding buttons to the back-end toolbar when developing components and modules.&lt;br /&gt;
==Explanation of  JToolBarHelper button functionality==&lt;br /&gt;
* When you add a JToolBarHelper function into an admin view it will display the icon and preform the corresponding function listed in the controller when pressed.&lt;br /&gt;
* You can modify the default function that is run by using the $this-&amp;gt;registerTask(&#039;add&#039;, &#039;edit&#039;); to redirect logic, in this example a call from the default button add is directed to the edit function.&lt;br /&gt;
&lt;br /&gt;
==Default Buttons / Functions Included with Joomla 1.5==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
JToolBarHelper::title();&lt;br /&gt;
JToolBarHelper::spacer();&lt;br /&gt;
JToolBarHelper::divider();&lt;br /&gt;
JToolBarHelper::custom();&lt;br /&gt;
JToolBarHelper::customX();&lt;br /&gt;
JToolBarHelper::preview();&lt;br /&gt;
JToolBarHelper::help();&lt;br /&gt;
JToolBarHelper::back();&lt;br /&gt;
JToolBarHelper::media_manager();&lt;br /&gt;
JToolBarHelper::addNew();&lt;br /&gt;
JToolBarHelper::addNewX();&lt;br /&gt;
JToolBarHelper::publish();&lt;br /&gt;
JToolBarHelper::publishList();&lt;br /&gt;
JToolBarHelper::makeDefault();&lt;br /&gt;
JToolBarHelper::assign();&lt;br /&gt;
JToolBarHelper::unpublish();&lt;br /&gt;
JToolBarHelper::unpublishList();&lt;br /&gt;
JToolBarHelper::archiveList();&lt;br /&gt;
JToolBarHelper::unarchiveList();&lt;br /&gt;
JToolBarHelper::editList();&lt;br /&gt;
JToolBarHelper::editListX();&lt;br /&gt;
JToolBarHelper::editHtml();&lt;br /&gt;
JToolBarHelper::editHtmlX();&lt;br /&gt;
JToolBarHelper::editCss();&lt;br /&gt;
JToolBarHelper::editCssX();&lt;br /&gt;
JToolBarHelper::deleteList();&lt;br /&gt;
JToolBarHelper::deleteListX();&lt;br /&gt;
JToolBarHelper::trash();&lt;br /&gt;
JToolBarHelper::apply();&lt;br /&gt;
JToolBarHelper::save();&lt;br /&gt;
JToolBarHelper::cancel();&lt;br /&gt;
JToolBarHelper::preferences();&lt;br /&gt;
JToolBarHelper::addEntry();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* The icons associated with these functions are stored at:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
www/administrator/templates/khepri/images&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Custom button==&lt;br /&gt;
* The syntax for a custom button that can be added into a view&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
/**&lt;br /&gt;
* Writes a custom option and task button for the button bar&lt;br /&gt;
* @param string The task to perform (picked up by the switch($task) blocks&lt;br /&gt;
* @param string The image to display&lt;br /&gt;
* @param string The image to display when moused over&lt;br /&gt;
* @param string The alt text for the icon image&lt;br /&gt;
* @param boolean True if required to check that a standard list item is checked&lt;br /&gt;
* @param boolean True if required to include callinh hideMainMenu() &lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
JToolBarHelper::custom( &#039;task&#039;, &#039;icon&#039;, &#039;icon over&#039;, &#039;alt&#039;, boolean, boolean );&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* The Default Admin Toolbar Icons are stored at:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
www/administrator/templates/khepri/images&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* From here you will notice that the icons are linked to display through the CSS file at:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
www/administrator/templates/khepri/css/icon.css&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* This icon CSS file is automatically included through the admin template. If we would like to add a custom toolbar icon into an installable component it is useful to follow the same structure. We will have to manually include our new CSS file. &lt;br /&gt;
&lt;br /&gt;
* An example of the icon CSS statement:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;css&amp;quot;&amp;gt;&lt;br /&gt;
.icon-32-iconname	{ &lt;br /&gt;
	background-image: url(../../images/icon-32-iconfile.png); &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* As you can see iconname and iconfile do not necessarily have to be the same.&lt;br /&gt;
** JToolBarHelper will look for the iconname at the end of .icon-32- and the filename must be preceded by icon-32-&lt;br /&gt;
&lt;br /&gt;
* The following would create this custom toolbar icon, notice the iconname dose not correspond to the actual file name but the CSS allows the reference.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
JToolBarHelper :: custom( &#039;someFunction&#039;, &#039;iconname.png&#039;, &#039;iconname.png&#039;, &#039;alt text&#039;, false, false );&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* You can place your icon file and css file at any point in your installable component, which will allow it to be easily transferable. &lt;br /&gt;
&lt;br /&gt;
* To include a new CSS file to your entire admin side it may be useful to include it in the entry point.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
JHTML::_(&#039;stylesheet&#039;, THISCOMPONENTNAME.css&#039;, &#039;components/THISCOMPONENT/assets/css/&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* A Custom button relies on javascript from includes/js/joomla.javascript.js to execute the task indicated by the user:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
function submitbutton(pressbutton) {&lt;br /&gt;
  submitform(pressbutton);&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
* In more complex cases a user can override this javascript by implementing his own submitbutton function. To keep the toolbar buttons in working order, the user has to replace the document.adminForm.task.value with the pressbutton value:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
function submitbutton(pressbutton) {&lt;br /&gt;
// Some conditions&lt;br /&gt;
  document.adminForm.task.value=pressbutton;&lt;br /&gt;
// More conditions&lt;br /&gt;
  submitform(pressbutton);&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Upload button==&lt;br /&gt;
* Method 1:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// Add an upload button and view a popup screen width 550 and height 400&lt;br /&gt;
$alt = &amp;quot;Upload&amp;quot;;&lt;br /&gt;
$bar=&amp;amp; JToolBar::getInstance( &#039;toolbar&#039; );&lt;br /&gt;
$bar-&amp;gt;appendButton( &#039;Popup&#039;, &#039;upload&#039;, $alt, &#039;index.php&#039;, 550, 400 );&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
* Method 2:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// You view button for popup media manager tools&lt;br /&gt;
JToolBarHelper::media_manager( &#039;/&#039; );&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Norbert73</name></author>
	</entry>
</feed>