0

This is my current customer_account.xml file I am able to get the tab to display inside of the account dashboard but I am not able to render the page I need.

My current file path is html/app/design/frontend/Babble/lighting/Magecomp_Savecartpro/layout/

Im lost on what would be the next step after this. I have followed some tutorials but they all are outdated.

<?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-myquote" after="-" ifconfig="savecartpro/general/enable">
                <arguments>
                    <argument name="path" xsi:type="string">savecartpro/customer/cartlist</argument>
                    <argument name="label" xsi:type="string">My Saved Projects</argument>
                </arguments>
            </block>
            <block class="Magento\Framework\View\Element\Html\Link\Current" name="customer-account-navigation-your-second-link" after="-" ifconfig="savecartpro/general/enable">
                <arguments>
                    <argument name="path" xsi:type="string">helloworld/index/index</argument>
                    <argument name="label" xsi:type="string">Your Second Link</argument>
                </arguments>
            </block>
        </referenceBlock>
    </body>
</page>

This is my full folder

This is driving me crazy enter image description here

1
  • Have you checked answer?
    – ZealousWeb
    Jun 25 at 11:22
0

Your above code is proper. Now you need to create controller file(according to the path you mentioned in xml file), after that need to create layout and phtml file same as below.

I assume that you have created routes.xml file already.

According to your code please create controller file cartlist.php under path PackageName/Module/Controller/Customer/

<?php
namespace PackageName\Module\Controller\Customer;

class Cartlist extends \Magento\Customer\Controller\AbstractAccount
{
    /**
     * @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
    ) {
        parent::__construct($context);
        $this->_resultPageFactory = $resultPageFactory;
    }
    
    /**
     * Prepare collection page
     */
    public function execute()
    {
        $this->resultPage = $this->_resultPageFactory->create();  
        return $this->resultPage;
    }
}

Now please create layout file savecartpro_customer_cartlist.xml under path PackageName/Module/view/frontend/layout/

<?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">
    <update handle="customer_account"/>
    <head>
        <title>Cart List</title>
    </head>
    <body>
        <referenceBlock name="page.main.title" remove="true" />
        <referenceContainer name="content">         
            <block class="PackageName\Module\Block\Customer\Cartlist" name="custom_list" template="custom/collection.phtml" cacheable="false"></block>
        </referenceContainer> 
    </body>
</page>

Please create collection.phtml file under path PackageName/Module/view/frontend/templates/custom/

<div class="">Test</div>

Please create block file Cartlist.php under path PackageName/Module/Block/Customer/

<?php
namespace PackageName\Module\Block\Customer;

use Magento\Framework\View\Element\Template\Context;
use Magento\Framework\View\Element\Template;

class Cartlist extends Template
{
    /**
    * @param \Magento\Framework\View\Element\Template\Context $context
    */

    public function __construct(
        Context $context,
        array $data = []
    ){
        parent::__construct($context, $data);
    }
}

Please create functions in block and show data in phtml file according to your need.

Cheers!

3
  • Sorry I have not created a routes xml the tutorial I followed never mentioned one
    – Carter
    Jun 25 at 18:17
  • am I supposed to add these files to the vender folder?
    – Carter
    Jun 25 at 20:34
  • Why in vendor folder? You should create custom module for that
    – ZealousWeb
    Jul 2 at 5:38

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.