1

I have made new custom tabs for my customer account dashboard. however, when I click the custom navigation link. It cannot find my controller action. enter image description here enter image description here

I cannot figure out the mistakes..so I need your help

Folder tree

My module structure


customer_account.xml

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
    <referenceBlock name="customer_account_navigation">
        <block class="Magento\Framework\View\Element\Html\Link\Current" name="customer-account-navigation-training-material-link" after="customer-account-navigation-address-link">
            <arguments>
                <argument name="path" xsi:type="string">trainingmaterial/customer/index</argument>
                <argument name="label" xsi:type="string"> Training Material</argument>
            </arguments>
        </block>
        <block class="Magento\Framework\View\Element\Html\Link\Current" name="customer-account-navigation-newsletter-link" after="customer-account-navigation-training-material-link">
            <arguments>
                <argument name="path" xsi:type="string">trainingmaterial/customer/newsletter</argument>
                <argument name="label" xsi:type="string">Newsletter</argument>
            </arguments>
        </block>            
    <referenceBlock name="customer-account-navigation-wish-list-link" remove="true"/>
    <referenceBlock name="customer-account-navigation-billing-agreements-link" remove="true"/>
    <referenceBlock name="customer-account-navigation-downloadable-products-link" remove="true"/>
    <referenceBlock name="customer-account-navigation-newsletter-subscriptions-link" remove="true"/>
    <referenceBlock name="customer-account-navigation-my-credit-cards-link" remove="true"/>                               
    </referenceBlock>
</body>


trainingmaterial_customer_index.xml

    <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
<update handle="customer_account"/>
<body>
    <referenceBlock name="page.main.title">
            <action method="setPageTitle">
                <argument translate="true" name="title" xsi:type="string">Training Material</argument>
            </action>
     </referenceBlock>
     <referenceContainer name="content">
            <block class="Magento\Cms\Block\Block" name="training">
                <arguments>
                    <argument name="block_id" xsi:type="string">training</argument>
                </arguments>
            </block>
    </referenceContainer>
</body>
</page>

trainingmaterial_customer_newsletter.xml

    <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
<update handle="customer_account"/>
<body>
    <referenceBlock name="page.main.title">
            <action method="setPageTitle">
                <argument translate="true" name="title" xsi:type="string">Newsletter</argument>
            </action>
     </referenceBlock>
     <referenceContainer name="content">
            <block class="Magento\Cms\Block\Block" name="training">
                <arguments>
                    <argument name="block_id" xsi:type="string">training</argument>
                </arguments>
            </block>
    </referenceContainer>
</body>
</page>

Index.php

class Index extends \Magento\Framework\App\Action\Action {

 public function execute() {

    $this->_view->loadLayout();

    $this->_view->renderLayout();
  }

}

Newsletter.php

class Newsletter extends \Magento\Framework\App\Action\Action {

 public function execute() {

    $this->_view->loadLayout();

    $this->_view->renderLayout();
  }

}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.