1

I am new to Magento & I am using Magento version 2.1.7 in my Windows 8.1 system with Xampp while creating a new module I am getting an error in my XML file located in the app/code/vendor/module/view/frontend/layout

with below error message

Element referenceContainer is not allowed here for the reference Container

cannot resolve symbol 'content' 

for the reference Container name

My Code is as follows

<?xml version="1.0"?>

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation=
        "urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="content">
                <block class="Funky\Hello\Block\Main"
                       template="blockContent.phtml"
                       name="funky_hello_HelloWorld"/>
        </referenceContainer>
    </body>
</page>

Please can some one tell me that what is the exact problem?

2
  • Well thats the separate error , But the reference content error will be solved by my below answer , also check in your template are you doing echo there ? Also have you clear the cache ? You need to put all files code like your .phtml file and your block as well Commented Jul 21, 2017 at 12:44
  • I have already checked my .phtml file I am echoing in my file. & by using your code it is now showing the below error can not resolve file page_configuration.xsd I am using phpstrom as an IDE my cache is disabled & than also I have cleared the cache by cmd Commented Jul 21, 2017 at 12:48

2 Answers 2

0

If you want to call your template with in module, you need to specify you module name Vendor_Module

<?xml version="1.0"?>

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation=
        "urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="content">
                <block class="Funky\Hello\Block\Main"
                       template="Vendor_Module::blockContent.phtml"
                       name="funky_hello_HelloWorld"/>
        </referenceContainer>
    </body>
</page>

Then, clear the cache and check it.

3
  • check my latest update Commented Jul 21, 2017 at 12:13
  • check your controller works fine.. go you you controller execute(), then command your return statement and write , echo "Testing" clear cache. Check it Now print your echo statement. Commented Jul 21, 2017 at 12:53
  • 1
    follow this answer magento.stackexchange.com/questions/88242/… Commented Jul 21, 2017 at 13:03
0

Try below code :

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

Also As per the coding standard it would be good to Remove extra space from xml tag and page tag.

Clear the cache and check

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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