Author Topic: Overriding a function createPrintLinks() in view.html.php?  (Read 307 times)

EvanGR

  • Jr. Member
  • **
  • Posts: 381
Overriding a function createPrintLinks() in view.html.php?
« 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

AH

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3358
  • VirtueMart Version: 3.8.8
Re: Overriding a function createPrintLinks() in view.html.php?
« Reply #1 on: December 28, 2020, 18:39:27 pm »
Yes you can override these - just add the function you want and display those new links
regards
A

Joomla 3.9.23
php 7.3

EvanGR

  • Jr. Member
  • **
  • Posts: 381
Re: Overriding a function createPrintLinks() in view.html.php?
« Reply #2 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

AH

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3358
  • VirtueMart Version: 3.8.8
Re: Overriding a function createPrintLinks() in view.html.php?
« Reply #3 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

Code: [Select]
<?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

Code: [Select]
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.
regards
A

Joomla 3.9.23
php 7.3