Follow bellow steps
Step : 1 (module.xml)
app/code/Ccc/HelloWorld/etc/module.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
<module name="Ccc_HelloWorld" setup_version="1.0.1">
</module>
</config>
Step : 2 (routes.xml)
app/code/Ccc/HelloWorld/etc/frontend/routes.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/App/etc/routes.xsd">
<router id="standard">
<route id="helloworld" frontName="helloworld">
<module name="Ccc_HelloWorld" />
</route>
</router>
</config>
Step : 3 (registration.php)
app/code/Ccc/HelloWorld/registration.php
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE,
'Ccc_HelloWorld',
__DIR__
);
Step : 4 (Index.php)
app/code/Ccc/HelloWorld/Controller/Index/Index.php
<?php
namespace Ccc\HelloWorld\Controller\Index;
use Magento\Framework\View\Result\PageFactory;
class Index extends \Magento\Framework\App\Action\Action
{
protected $resultPageFactory;
/** * @param \Magento\Framework\App\Action\Context $context */
public function __construct(\Magento\Framework\App\Action\Context $context,PageFactory $resultPageFactory)
{
$this->resultPageFactory = $resultPageFactory;
parent::__construct($context);
}
public function execute()
{
$resultPage = $this->resultPageFactory->create();
$resultPage->getConfig()->getTitle()->prepend(__('Hello World'));
return $resultPage;
}
}
Step : 5 (HelloWorld.php)
app/code/Ccc/HelloWorld/Block/HelloWorld.php
<?php
namespace Ccc\HelloWorld\Block;
class HelloWorld extends \Magento\Framework\View\Element\Template
{
public function _prepareLayout()
{
return parent::_prepareLayout();
}
}
Step : 6 (helloworld_index_index.xml)
app/code/Ccc/HelloWorld/view/frontend/layout/helloworld_index_index.xml
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="content">
<block class="Ccc\HelloWorld\Block\HelloWorld" name="helloworld" template="helloworld.phtml">
</block>
</referenceContainer>
</body>
</page>
Step : 7 (helloworld.phtml)
app/code/Ccc/HelloWorld/view/frontend/templates/helloworld.phtml
<?php
echo 'Successful! This is a simple module in Magento 2.0';
?>
Step : 8 (rerun magento setup - this will re-generate app/etc/config.php & enable the module)
php-cli bin/magento setup:upgrade
I also flush the cache of the admin panel.
You need to create depending on what theme are you using the folder structure as following:
app/design/Magento/theme_name/Magento_Theme/layout/default.xml where theme_name has to be changed with the current active theme ( you can find that from the Magento admin, it's "luma" or "blank" but most likely is "luma"
So your final code for that file should be:
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="sidebar.main">
<block class="Magento\Theme\Block\Html\Topmenu" name="catalog.topnav.aside" template="html/topmenu-aside.phtml" ttl="3600" before="-"/>
</referenceContainer>
<referenceBlock name="catalog.topnav" remove="true" />
</body>
</page>
Create the following structure for removing the catalog.left nav from Layered navigation
app/design/Magento/theme_name/Magento_LayeredNavigation/layout/catalog_category_view_type_layered.xml and add the following code
<?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="catalog.leftnav" remove="true" />
</body>
</page>
Best Answer
If you installed the module manually: remove the folder
app/code/<Vendor>/<Module>
drop module tables from database remove the config settings.remove the module
<Vendor>_<Module> from app/etc/config.php
remove the module
<Vendor>_<Module> from table setup_module
Then next follow the command upgrade and compile.
If you installed it via composer:
run this in console:
Thanks.