New button type
Posted: Sun Jul 26, 2009 10:53 am
This modifies files class.module.inc.php & modform.inc.php
From the standard library we have an assortment of form objects - form start, form end, radio button, input submit, input reset, etc.
We have something called CreateLink, to return a textual link to somewhere.
I wanted a button that didn't 'submit', didn't 'reset', but went to a specified href, and so in file class.module.inc.php I made something called CreateInputButton, which provides an onClick event.
As with other functions in this file, it's a wrapper for file modform.inc.php function called cms_module_CreateInputButton.
What does this give me?
It gives me a button, text or graphic. that goes to a particular href., rather than submit/reset.
For example:
the long way
$_link = $this->CreateLink($id, 'order', $returnid, $this->Lang('start_checkout_process'), array('perfaction'=>'request_ship_to_info'), '', TRUE) ;
$this->CreateInputButton($id, $name, $this->Lang('continue_checkout_process'), '', '', $_link );
the short way
$this->CreateInputButton($id, $name, $this->Lang('continue_checkout_process'), '', '',
$this->CreateLink($id, 'order', $returnid, $this->Lang('start_checkout_process'), array('perfaction'=>'request_ship_to_info'), '', TRUE));
In the long way, the link is creating seperately, then added to the new button parameter.
In the short way, the link generation is part of the parameter.
The way these end up is shown in the attached image.
The code used for these buttons is:
Checkout Button
$this->smarty->assign('startcheckout',
$this->CreateInputButton($id, $name, $this->Lang('continue_checkout_process'), '', '',
$this->CreateLink($id, 'order', $returnid, $this->Lang('start_checkout_process'), array('perfaction'=>'request_ship_to_info'), '', TRUE)));
Continue Shopping Button
$this->smarty->assign('continueshopping',
$this->CreateInputButton($id, $name, $this->Lang('continueshopping'), '', '',
$this->CreateLink($id, 'continueshopping', $returnid, '', array(returnid=>$returnid), '', TRUE)) );
The modification I made to the library files are:
class.module.inc.php
function CreateInputButton($id, $name, $value='', $image='', $addttext='', $url='')
{
$this->LoadFormMethods();
return cms_module_CreateInputButton($id, $name, $value, $image, $addttext, $url);
}
modform.inc.php
function cms_module_CreateInputButton($id, $name, $value='', $image='', $addttext='', $url='')
{
$id = cms_htmlentities($id);
$name = cms_htmlentities($name);
$text = '';
return $text . "\n";
}
Again, see the attached image for a couple of butons creating this way.
Fat Lizard
From the standard library we have an assortment of form objects - form start, form end, radio button, input submit, input reset, etc.
We have something called CreateLink, to return a textual link to somewhere.
I wanted a button that didn't 'submit', didn't 'reset', but went to a specified href, and so in file class.module.inc.php I made something called CreateInputButton, which provides an onClick event.
As with other functions in this file, it's a wrapper for file modform.inc.php function called cms_module_CreateInputButton.
What does this give me?
It gives me a button, text or graphic. that goes to a particular href., rather than submit/reset.
For example:
the long way
$_link = $this->CreateLink($id, 'order', $returnid, $this->Lang('start_checkout_process'), array('perfaction'=>'request_ship_to_info'), '', TRUE) ;
$this->CreateInputButton($id, $name, $this->Lang('continue_checkout_process'), '', '', $_link );
the short way
$this->CreateInputButton($id, $name, $this->Lang('continue_checkout_process'), '', '',
$this->CreateLink($id, 'order', $returnid, $this->Lang('start_checkout_process'), array('perfaction'=>'request_ship_to_info'), '', TRUE));
In the long way, the link is creating seperately, then added to the new button parameter.
In the short way, the link generation is part of the parameter.
The way these end up is shown in the attached image.
The code used for these buttons is:
Checkout Button
$this->smarty->assign('startcheckout',
$this->CreateInputButton($id, $name, $this->Lang('continue_checkout_process'), '', '',
$this->CreateLink($id, 'order', $returnid, $this->Lang('start_checkout_process'), array('perfaction'=>'request_ship_to_info'), '', TRUE)));
Continue Shopping Button
$this->smarty->assign('continueshopping',
$this->CreateInputButton($id, $name, $this->Lang('continueshopping'), '', '',
$this->CreateLink($id, 'continueshopping', $returnid, '', array(returnid=>$returnid), '', TRUE)) );
The modification I made to the library files are:
class.module.inc.php
function CreateInputButton($id, $name, $value='', $image='', $addttext='', $url='')
{
$this->LoadFormMethods();
return cms_module_CreateInputButton($id, $name, $value, $image, $addttext, $url);
}
modform.inc.php
function cms_module_CreateInputButton($id, $name, $value='', $image='', $addttext='', $url='')
{
$id = cms_htmlentities($id);
$name = cms_htmlentities($name);
$text = '';
return $text . "\n";
}
Again, see the attached image for a couple of butons creating this way.
Fat Lizard