2

I am created a New Link in Dashboard Navigation Panel and it is showing and working fine. But when I navigating the dashboard links are not showing in my form.

See below pic My Custom Link in Dashboard page.

enter image description here

When I navigating it is not showing Dasboard links.

enter image description here

for this I am written below code.

view/frontend/layout/customer_account.xml

<?xml version="1.0"?>
<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="demo-link">
                <arguments>
                    <argument name="path" xsi:type="string">custompagelink</argument>
                    <argument name="label" xsi:type="string">Demo Link</argument>
                </arguments>
            </block>
        </referenceBlock>
    </body>
</page>

Controller/Index/Index.php

<?php
namespace Test\CustomLink\Controller\Index;

class Index extends \Magento\Framework\App\Action\Action
{
    /**
     * @var \Magento\Framework\View\Result\PageFactory
     */
    protected $resultPageFactory;

    /**
     * @param \Magento\Framework\App\Action\Context $context
     * @param \Magento\Framework\View\Result\PageFactory resultPageFactory
     */
    public function __construct(
        \Magento\Framework\App\Action\Context $context,
        \Magento\Framework\View\Result\PageFactory $resultPageFactory
    )
    {
        $this->resultPageFactory = $resultPageFactory;
        parent::__construct($context);
    }

    /**
     * Default customer account page
     *
     * @return void
     */
    public function execute()
    {
        return $this->resultPageFactory->create();
    }
}

view/frontend/layout/custompagelink_index_index.xml

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="content">
            <block class="Test\CustomLink\Block\CustomPage" name="custompage" template="custompage.phtml" />
        </referenceContainer>
    </body>
</page>

Block/CustomPage.php

<?php
namespace Test\CustomLink\Block;

class CustomPage extends \Magento\Framework\View\Element\Template
{

}

view/frontend/templates/custompage.phtml

<h1>Custom Form</h1>

Any help on this?

1

Change your custompagelink_index_index.xml as below

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-left" xsi:noNamespaceSchemaLocation="urn: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">Your Title</argument>
        </action>
    </referenceBlock>
        <referenceContainer name="content">
            <block class="Test\CustomLink\Block\CustomPage" name="custompage" template="Test_CustomLink::custompage.phtml" />
        </referenceContainer>
    </body>
</page>

I have added <update handle="customer_account"/> in above code that is responsible for dashboard link. Also changed template path so it will take template from your custom module

5
  • no luck. just changed page title Billing Agreements. still not showing side navigation links.
    – Bojjaiah
    Dec 15 '16 at 7:15
  • updated xml file try with it Dec 15 '16 at 7:23
  • now working fine. where I need to change page title? it is showing Billing Agreements
    – Bojjaiah
    Dec 15 '16 at 7:27
  • update answer check it Dec 15 '16 at 7:31
  • @Prashanth There is two issues if I use this xml 1) My custom link is not showing in left side navigation list 2) My custom phtml is showing fine but it is showing in dashboard content section top.I need it as a separate page same like other pages. Dec 19 '16 at 6:27

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.