Hello @RalfBecker,
thanks for your reply, it helped me search at the right place. The different class name currency2 at the commented out code was a desperate action while trying to find out why things where not working⊠Nevertheless I actually had made 2 similar mistakes:
- I had forgotten the â.inc.â letters in the filename of my class file, so it was not autoloaded.
- I made an error when using the Api\Framework::includeJS("/$app/$file") function you mentioned.
After that I can confirm that moving a widget to a custom application is straight forward. Letâs say
- the application is called âachelperâ,
- the widget is called âcurrencyâ
- then the php class should be named achelper_widget_currency and the classfile class.achelper_widget_currency.inc.php
- the js file is named et2_widget_currency.js
Steps:
- In the setup.inc.php of the achelper application add the âetemplate2_register_widgetsâ hook to a static function:
$setup_info[âachelperâ][âhooksâ][âetemplate2_register_widgetsâ] = âachelper_hooks::widgetsâ;
- In the achelper_hooks class add a static function, in this case named widgets as defined in setup.inc.php returning the widget class:
/**
Returns a list of custom widgets classes for etemplate2
*/
public static function widgets()
{
return [âachelper_widget_currencyâ];
}
- Put the js file âet2_widget_currency.jsâ in the js folder of the achelper app:
/achelper/js/et2_widget_currency.js
- Include the js file in the constructor of the php class:
**
eTemplate currency textbox
Supports formatting for decimal & thousands, and currency prefix/suffix
*/
class achelper_widget_currency extends Etemplate\Widget
{
public function __construct($xml=ââ) {
Api\Framework::IncludeJS("/achelper/js/et2_widget_currency.js");
parent::__construct($xml);
}
Including in the beforeSendToClient() function works also fine, I donât know which is the better placeâŠ
Now my last question about this is how the et2_widget_currency.js can be included in the min.js files. I included it in the Gruntfile.js in the Egroupware root and ran âgruntâ but my widget is still using the uncompressed version.
Thanks again everyone and Best Regards,
Alex