Magento2 missing theme and view names in static URLs

Viewed 35

I've created a custom tab in user panel with following one of many tutorials online. "Technically" it seem to work but on custom page CSS and JS files are not loading due to problem with their URL scheme.

Here is an example URLs from different page.

https://example.com/static/frontend/Codazon/unlimited_supermarket/tr_TR/css/styles-m.css

https://example.com/static/_cache/merged/1cf2235f8adc378c1b685431fc4c1ae3.js

And this is problematic JS from different custom page. (Same CSS not enqueued here) https://example.com/static/frontend/_view/tr_TR/requirejs/require.js

All I can say for a reason Magento not using my theme in this custom page and all theme related static content is missing but I don't know why. My guess is some sort of priority problem, my module renders page before theme initalizes.

Here are my codes for creating custom page.

app/code/Test/Module/view/frontend/layout/customer_account.xml

<?xml version="1.0" encoding="UTF-8"?>
<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="custom-tab-link">
            <arguments>
                <argument name="path" xsi:type="string">offers/customer/index</argument>
                <argument name="label" xsi:type="string">Fırsatlar</argument>
            </arguments>
        </block>
    </referenceBlock>
</body>

app/code/Test/Module/Controller/Customer/Index.php

<?php

namespace Test\Module\Controller\Customer;

class Index extends \Magento\Framework\App\Action\Action
{
    public function execute()
    {
        $this->_view->loadLayout();
        $this->_view->renderLayout();
    }
}

app/code/Test/Module/view/frontend/layout/offers_customer_index.xml

<?xml version="1.0" encoding="UTF-8"?>
<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">Fırsatlar</argument>
        </action>
    </referenceBlock>
    <referenceContainer name="content">
        <block class="Magento\Framework\View\Element\Template" name="custom-tab" template="Test_Module::customer/account/offers_tab.phtml" />
    </referenceContainer>
</body>

app/code/Test/Module/etc/frontend/routes.xml

<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
<router id="standard">
    <route frontName="offers" id="offers">
        <module name="Test_Module"/>
    </route>
</router>
0 Answers
Related