VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: EvanGR on December 28, 2020, 12:11:02 PM

Title: Overriding a function createPrintLinks() in view.html.php?
Post by: EvanGR on December 28, 2020, 12:11:02 PM
Hello,

I am looking to customize the Orders admin page, specifically the order print links.
The relevant code is function createPrintLinks($order,&$print_link,&$deliverynote_link,&$invoice_links)
in administrator\components\com_virtuemart\views\orders\view.html.php
Is it possible to override this (just the specific function would be better) in my template?

Thanks
Title: Re: Overriding a function createPrintLinks() in view.html.php?
Post by: AH on December 28, 2020, 18:39:27 PM
Yes you can override these - just add the function you want and display those new links
Title: Re: Overriding a function createPrintLinks() in view.html.php?
Post by: EvanGR on December 29, 2020, 10:50:16 AM
Thank you.

That function belongs to the "Controller" file. The template overrides usually work on the "View" layer (assuming MVC architecture).
If I override that function, or create a new one, in my template, I will be mixing Controller logic in the View layer.
That is my main concern, maybe there was a proper way of doing it, I am now aware of.

Thanks again
Title: Re: Overriding a function createPrintLinks() in view.html.php?
Post by: AH on December 29, 2020, 12:03:40 PM
I just added my own link function in my template override and called it in the same override - I would not worry about MVC for this simple override


<?php //create my own links for printing etc
MYcreatePrintLinks($order,$print_link,$deliverynote_link,$invoice_links,$pickinglist_link$returnslist_link);
?>



and then at the bottom of the code somewhere out of the way


function MYcreatePrintLinks($order,&$print_link,&$deliverynote_link,&$invoice_links,&$pickinglist_link, &$returnslist_link){
$baseUrl = 'index.php?option=com_virtuemart&view=orders&task=callInvoiceView&tmpl=component&virtuemart_order_id=' . $order->virtuemart_order_id;

    $deliverynote_link = '';
$pickinglist_link = '';
$returnslist_link = '';


etc etc.