I have a custom theme in magento 2 website.
In home page i called a banner slider(Banner_slider is a custom module)
I called the slider like this in home_content.phtml(design/frontend/company/projectname/Magento_theme/templates/home-content.phtml) like this
<?php include ($block->getTemplateFile('Company_Bannermanager::bannermanager.phtml')) ?>
location of bannermanager.phtml is - (app\code\Company\Bannermanager\view\frontend\templates)
In this file i called the block method(getHomepageBanners()) like this
<?php $home_banners = $block->getHomepageBanners(); ?>
Block file location is -( app\code\Company\Bannermanager\Block\Index )
I am getting this error
Error filtering template: Warning: Invalid argument supplied for foreach() in D:\xampp\htdocs\mollys_spirits\app\code\Company\Bannermanager\view\frontend\templates\bannermanager.phtml on line 17
I know i can call this block like below
<?php
$blockObj= $block->getLayout()->createBlock('Company\Bannermanager\Block\Index\Index');
$home_banners = $blockObj->getHomepageBanners(); ?>
What part i am missing in first method.
Update
My layout file is homebanner_index_index.xml-(app\code\Eight25media\Bannermanager\view\frontend\layout)
<?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">
<head>
<title>Banners</title>
</head>
<body>
<referenceContainer name="content">
<block class="Company\Bannermanager\Block\Index\Index" name="homebanner" template="Company_Bannermanager::bannermanager.phtml"/>
</referenceContainer>
</body>
homebanner_index_index.xml
? Is there a custom controller?