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.
When I navigating it is not showing Dasboard links.
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 Answer 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
-
no luck. just changed page title Billing Agreements. still not showing side navigation links.Bojjaiah– Bojjaiah2016年12月15日 07:15:22 +00:00Commented Dec 15, 2016 at 7:15
-
updated xml file try with itPrashant Valanda– Prashant Valanda2016年12月15日 07:23:17 +00:00Commented Dec 15, 2016 at 7:23
-
now working fine. where I need to change page title? it is showing Billing AgreementsBojjaiah– Bojjaiah2016年12月15日 07:27:11 +00:00Commented Dec 15, 2016 at 7:27
-
update answer check itPrashant Valanda– Prashant Valanda2016年12月15日 07:31:20 +00:00Commented Dec 15, 2016 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.shankar boss– shankar boss2016年12月19日 06:27:05 +00:00Commented Dec 19, 2016 at 6:27