I am rebuilding an old 1.x module for Magento 2, adding a "customer invoices" page to the Customer Account section of the site, which brings in PDF invoices from a proprietary external source.
I have accomplished:
- respond to the request at /my_invoices/invoices/index with an action controller and serve the appropriate view, template, etc
- add a link to that page in the customer_account_navigation links block
With these I can "make it work" but I would like to tie the UI together to make it look like the customer is still in the Customer Account section.
What I need to do is bring that customer_account_navigation menu to my custom page at /my_invoices/invoices/index.
In the app/code/MyNamespace/CustomerInvoices/view/frontend/layout/my_invoices_invoices_index.xml file I attempted to reference the sidebar.main container and add a customer_account_navigation block:
<?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-left" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd"> <referenceBlock name="content"> <block template="invoices/index/content.phtml" class="MyNamespace\CustomerInvoices\Block\Invoices" name="my_customerinvoices"/> </referenceBlock> <body> <referenceContainer name="sidebar.main"> <block class="Magento\Framework\View\Element\Html\Links" name="customer_account_navigation" before="-" template="Magento_Customer::account/navigation.phtml"> <block class="Magento\Framework\View\Element\Html\Link\Current" name="customer-account-invoices-link"> <arguments> <argument name="label" xsi:type="string" translate="true">Invoices</argument> <argument name="path" xsi:type="string">my_invoices/invoices</argument> </arguments> </block> </block> </referenceContainer> </body> </page>
But this results in only the explicitly defined link to my invoices page appears in the menu. I would like to have all of the links that normally appear on the sidebar menu in the customer account area to also appear here.
Is there a way to tell the XML to simply inherit the links from all the other modules that populate that menu?