Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Joomla 1.5, component developement, how to mak a button on toolbar clickable

Posted on 2008-10-08
9
1,301 Views
Last Modified: 2013-11-19
I'm trying to implement the review component provided in the book Learing Joomla! 1.5  Extension Development.

I have a tool bar from the two files toolbar.vnrbooking.html.php and in toolbar.vnrbooking.php and they are displayed correctly.

Now, I would like to click on the New button to create a new entry, but cliking on thr button on the button has no effect.

I don't understand how it shall work, here is my admin.vnrboking.php file. Is there something missing?

<?php
defined ('_JEXEC') or die ('Restricted access');
require_once( JApplicationHelper::getPath( 'admin_html' ) );
JTable::addIncludePath(JPATH_COMPONENT.DS.'tables');
switch($task)
{
    case 'edit':
    case 'add':
        editBooking($option );
        break;
    case 'save':
        saveBooking($option );
        break;
    case 'remove':
        removeBoking($option);
    default:
        showBooking($option);
        break;
}
function editBooking($option)
{
    $row =& JTable::getInstance('Vnrbooking', 'Table');
    $cid = JRequest::getVar('cid', array(0), '', 'array');
    $id = $cid[0];
    $row->load($id);
    $lists = array();
    $present = array(
        '0' => array('value' => 'Sera présent', 'text' => 'Sera présent'),

        '1' => array('value' => 'Présent église', 'text' => 'Sera présent uniquement à église'),

        '2' => array('value' => 'Ne peut pas venir', 'text' => 'Ne peut pas venir'),
    );

    $lists['present'] = JHTML::_('select.genericlist', $present, 'present', 'class="inputbox" '. '', 'value',
        'text', $row->present );
    $lists['published'] = JHTML::_('select.booleanlist', 'published', 'class="inputbox"',
        $row->published );
    HTML_vnrbooking::editBooking($row, $lists, $option);
}

function saveBooking($option)
{
    global $mainframe;
    $row =& JTable::getInstance('vnrbooking','Table');
    if(!$row->bind(JRequest::get('post')))
    {
        JError::raiseError(500, $row->getError() );
    }
    if(!$row->confirmation_date)
        $row->confirmation_date = date( 'Y-m-d H:i:s');
    if(!$row->store())
    {
      JError::raiseError(500, $row->getError() );
    }
    $mainframe->redirect('index.php?option=' .
        $option, 'Booking Saved');
}

function showBooking($option)
{
    $db =& JFactory::getDBO();
    $query = "SELECT * FROM #__vnrbooking";
    $db->setQuery($query);
    $rows = $db->loadObjectList();
    if($db->getErrorNum())
    {
        echo $db->stderr();
        return false;
    }
    HTML_vnrbooking::showBooking($option,$rows);
}

function removeBooking($option)
{
    global $mainframe;
    $cid = JRequest::getVar('cid', array(), '', 'array');
    $db =& JFactory::getDBO();
    if(count($cid))
    {
        $cids = implode(',', $cid);
        $query = "DELETE FROM #__vnrbooking WHERE id IN ($cids)";
        $db->setQuery($query);
        if(!$db->query())
        {
           echo "<script> alert('".$db->getErrorMsg()."');
           window.history.go(-1); </script>\n";
        }
    }
    $mainframe->redirect('index.php?option=' . $option);
}
?>
0
Comment
Question by:pviret
  • 5
  • 4
9 Comments
 
LVL 3

Expert Comment

by:binarygeek
ID: 22680014
hi add the code below to your toolbar.vnrbooking.php
<?php
defined( '_JEXEC' ) or die( 'Restricted access' );
require_once( JApplicationHelper::getPath( 'toolbar_html' ) );
switch($task)
{
default:
TOOLBAR_vnrbooking::_DEFAULT();
break;
}
?>

Open in new window

0
 
LVL 3

Expert Comment

by:binarygeek
ID: 22680049
then make a file toolbar.vnrbooking.html.php and add the following code

<?php
defined( '_JEXEC' ) or die( 'Restricted access' );
class TOOLBAR_vnrbooking {
 
function _DEFAULT() {
JToolBarHelper::title( JText::_( VNR booking),'generic.png' );
JToolBarHelper::publishList();
JToolBarHelper::unpublishList();
JToolBarHelper::editList();
JToolBarHelper::addNew();
JToolBarHelper::deleteList();
}
 
}

Open in new window

0
 
LVL 3

Expert Comment

by:binarygeek
ID: 22680059
this will create your working default toolbar , and you can make other cases and functions according to you $task
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 

Author Comment

by:pviret
ID: 22681080
That is what I've done, my toolbar.vnrbooking.html.php is
<?php
defined ('_JEXEC') or die ('Restricted access');
class TOOLBAR_vnrbooking {
    function _NEW() {
        JToolBarHelper::save();
        JToolBarHelper::apply();
        JToolBarHelper::cancel();
    }
 
    function _DEFAULT() {
        JToolBarHelper::title( JText::_( 'VNR Booking' ), 'generic.png' );
        JToolBarHelper::publishList();
        JToolBarHelper::unpublishList();
        JToolBarHelper::editList();
        JToolBarHelper::deleteList();
        JToolBarHelper::addNew();
    }
}
?>

Open in new window

0
 

Author Comment

by:pviret
ID: 22681089
And my toolbar.vnrbooking.php is
<?php
defined ('_JEXEC') or die ('Restricted access');
require_once( JApplicationHelper::getPath( 'toolbar_html' ) );
switch($task)
{
    case 'edit':
    case 'add':
        TOOLBAR_vnrbooking::_NEW();
        break;
    
    default:
        TOOLBAR_vnrbooking::_DEFAULT();
        break;
}
?>

Open in new window

0
 

Author Comment

by:pviret
ID: 22681119
The toolbar is displayed correctly, but when I click on new button I don't get the

http://localhost/joomla-157/administrator/index.php?option=com_vnrbooking&task=add 

url as expected, but only the following url

http://localhost/joomla-157/administrator/index.php?option=com_vnrbooking# 

that's the same for the other buttons.
0
 
LVL 3

Expert Comment

by:binarygeek
ID: 22686873
Please try adding this just after the current function in admin.vnrbooking.html.php
<script language="javascript" type="text/javascript">
function submitbutton(pressbutton) {
var form = document.adminForm;
if (pressbutton == 'cancel') {
submitform( pressbutton );
return;
} else {
submitform( pressbutton );
}
}
</script>

Open in new window

0
 
LVL 3

Accepted Solution

by:
binarygeek earned 500 total points
ID: 22686882
Also please make sure your form name is adminForm and it has atleast following hidden fields
<input type="hidden" name="option" value="<?php echo $option;?>" />
<input type="hidden" name="task" value="" />
<input type="hidden" name="boxchecked" value="0" />
0
 

Author Closing Comment

by:pviret
ID: 31504375
Thank you for your help, I had also some other problem but I found a way
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Randomize in Owl Carousel v1.3.2 6 68
compact pure CSS Read More Toggle 4 152
Eloquent ORM manual paginator defaults to simple 2 31
youtube blocking politics 4 55
Any business that wants to seriously grow needs to keep the needs and desires of an international audience of their websites in mind. Making a website friendly to international users isn’t prohibitively expensive and can provide an incredible return…
Get to know the ins and outs of building a web-based ERP system for your enterprise. Development timeline, technology, and costs outlined.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question