Custom PDF Button

wildmanmatt

New member
Hi,

I am trying to create a custom button that will generate a PDF from an existing template.

I already have the PDF template working via the PDF button and dropdown. The template file is called Card.php (and the associated Card_settings.php

I have added the following settings to my settings_custom.php:
$parse_pdf_php_template_even_if_export_pdf_disable = 1;
$enable_custom_button_functions = 1;
$export_to_pdf_feature = 1;

I have added the following to custom_buttons.php:
$cnt = 1;
$custom_buttons['cardprint'][$cnt]['type'] = 'javascript';
$custom_buttons['cardprint'][$cnt]['callback_function'] = 'dadabik_card_print';
$custom_buttons['cardprint'][$cnt]['permission_needed'] = 'none';
$custom_buttons['cardprint'][$cnt]['show_in'][] = 'edit_form';
$custom_buttons['cardprint'][$cnt]['show_in'][] = 'details_page';
$custom_buttons['cardprint'][$cnt]['position_form'] = 'top';
$custom_buttons['cardprint'][$cnt]['label_type'] = 'fixed';
$custom_buttons['cardprint'][$cnt]['label'] = 'PRINT Card';
$custom_buttons['cardprint'][$cnt]['style'] = 'background:#2e4472;width:200px';
$cnt++;

I have tried the following code in custom_functions.js :
function dadabik_diverlog_card_print($table_name, $where_field, $where_value)
{
header('Location:index.php?tablename=membersdatabase&function=search&export_to_pdf=1&pdf_template=Card');
exit();
}

I did also try putting that code in custom_required_functions.php and changing the button type to 'php_standard', but that didn't work either.

The button isn't even showing up for me on the edit view or the record details view.

I'm not sure what I'm doing wrong?

I tried to follow the manual and also the information from this post: https://dadabik.com/forum/read.php?1,20784,20786#msg-20786

Thanks,

Matt
 

Martin

New member
hi,

I've noticed that the name of the function is in your button definition is not the same as where you declare your function:

$custom_buttons['cardprint'][$cnt]['callback_function'] = 'dadabik_card_print'; should be $custom_buttons['cardprint'][$cnt]['callback_function'] = 'dadabik_diverlog_card_print';

if I understood the system correctly... I've never used it myself so far...

BR
Martin
 

eugenio

Administrator
Staff member
Martin is right, I didn't notice that the two names differs.

Also consider that:

1) It seems you are writing PHP code for a javascript function, if you need a javascript function, you have to write javascript code
2) custom_required_functions.php is for the custom required functions, not for buttons

Best,
 

wildmanmatt

New member
I've adjusted the function name and corrected that error, but I still can't get the button to show up.

What kind of checks are there within the system before showing a custom button? I've even tried copying over a button from one of the prepackaged app (along with its associated function) but even that doesn't show a button for me.

Is there maybe a setting I'm missing to allow custom buttons to show?

When I created it as a hook, it showed up straight away, but I just don't seem to be able to get a custom button to show

Thanks,

Matt
 
Top