If you’ve ever tried to add buttons to the top of a Detail View, you know it’s not a difficult process. Typically a simple adjustment to the MetaData is all that is needed. Changes are straight-forward and upgrade-safe. But that’s not the case with the Quotes module.The Quotes module, because it must invoke different sets of buttons depending on which PDF engine the system uses, re-defines the button array in the view.detail.php instead of the metadata. This makes customization of the button array difficult, because you have to extend the QuotesViewDetail class (using CustomQuotesViewDetail), specifically the display() function. Display of course calls the view directly and so you don’t really have access to override the overridden button array without copy-and-pasting the entire function.
In the example I’m working on tonight, I’ve copied the file as described above, I’ve adjusted the end of the display method to the following before invoking parent::display() (which will actually echo out the content of the page).
$new_array = array(); $MyNewCustomCodeButton = "<input type='button' onclick='SomeAction();' value='Click me' />"; $new_array = $this->dv->defs['templateMeta']['form']['buttons']; // EDIT $new_array = $this->dv->defs['templateMeta']['form']['buttons']; // DUPLICATE $new_array = $this->dv->defs['templateMeta']['form']['buttons']; // DELETE $new_array = array('customCode' => $MyNewCustomCodeButton); $new_array = $this->dv->defs['templateMeta']['form']['buttons']; // quote2opp $new_array = $this->dv->defs['templateMeta']['form']['buttons']; // quote2pdf $this->dv->defs['templateMeta']['form']['buttons'] = $new_array; parent::display();