我正在尝试在客户帐户导航中添加自定义链接。我的自定义链接也显示在帐户导航中,并且也可以正常工作,但是单击时并没有显示为活动/当前状态。
下面是我的代码:
/app/code/Namespace/Support/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="customer-account-navigation-suppport-ticket-link" after="-">
<arguments>
<argument name="path" xsi:type="string">support/customer/index</argument>
<argument name="label" xsi:type="string">Support Ticket</argument>
</arguments>
</block>
</referenceBlock>
</body>
</page>
/ app / code /命名空间/Support/Controller/Customer/Index.php
<?php
namespace Namespace\Support\Controller\Customer;
use Magento\Framework\App\Action;
use Magento\Framework\Exception\NotFoundException;
use Magento\Framework\Controller\ResultFactory;
class Index extends \Namespace\Support\Controller\Index
{
/**
* Show customer tickets
*
* @return \Magento\Framework\View\Result\Page
* @throws NotFoundException
*/
public function execute()
{
/** @var \Magento\Framework\View\Result\Page resultPage */
$resultPage = $this->resultFactory->create(ResultFactory::TYPE_PAGE);
return $resultPage;
}
}
/app/code/Namespace/Support/view/frontend/layout/support_customer_index.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">
<update handle="customer_account"/>
<head>
<title>Support Ticket</title>
<css src="Namespace_Support::css/styles.css"/>
</head>
<body>
<referenceContainer name="content">
<block class="Namespace\Support\Block\TicketList" name="ticketViewList" template="Namespace_Support::list.phtml" />
</referenceContainer>
</body>
</page>
让我知道是否有帮助
—
Codrain Technolabs Pvt Ltd
@YagneshPonkiya。感谢您的快速回复。是的,它正在工作。将您的评论作为答案,以便我接受。
—
Shyam
@YagneshPonkiya。另外,您能告诉我问题是什么吗?为什么我们需要改变呢?提前致谢。
—
Shyam
@Shyam,您完成了此模块吗?我正在M2项目中创建相同的功能。因此,能否请您指导我如何创建此功能?谢谢
—
mageDev0688 '17
<argument name="path" xsi:type="string">support/customer/index</argument>
到<argument name="path" xsi:type="string">support/customer</argument>