-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1.- ejemplo completo tomado de : https://www.mageplaza.com/magento-2-module-development/ Objetivo : crear una Pagina [vista] en el FRONTEND que cargue los registros de una tabla Step 0: Create module Step 1: Create routes.xml file Step 2: Create controller file Step 3: Create controller Layout file Step 4: Create controller Block file Step 5: Create controller template file Step 6: Flush Magento cache Step 7: Run a test new controller
- Loading branch information
1 parent
01ff7b6
commit 16f8c38
Showing
9 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?php | ||
namespace Mageplaza\HelloWorld\Block; | ||
class Index extends \Magento\Framework\View\Element\Template | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
namespace Mageplaza\HelloWorld\Controller\Index; | ||
|
||
class Index extends \Magento\Framework\App\Action\Action | ||
{ | ||
protected $_pageFactory; | ||
|
||
public function __construct( | ||
\Magento\Framework\App\Action\Context $context, | ||
\Magento\Framework\View\Result\PageFactory $pageFactory) | ||
{ | ||
$this->_pageFactory = $pageFactory; | ||
return parent::__construct($context); | ||
} | ||
|
||
public function execute() | ||
{ | ||
return $this->_pageFactory->create(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
namespace Mageplaza\HelloWorld\Controller\Index; | ||
|
||
class Test extends \Magento\Framework\App\Action\Action | ||
{ | ||
protected $_pageFactory; | ||
|
||
public function __construct( | ||
\Magento\Framework\App\Action\Context $context, | ||
\Magento\Framework\View\Result\PageFactory $pageFactory) | ||
{ | ||
$this->_pageFactory = $pageFactory; | ||
return parent::__construct($context); | ||
} | ||
|
||
public function execute() | ||
{ | ||
echo "Hello World"; | ||
exit; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?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="hellomageplaza" id="hellomageplaza"> | ||
<module name="Mageplaza_HelloWorld"/> | ||
</route> | ||
</router> | ||
</config> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0"?> | ||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> | ||
<module name="Mageplaza_HelloWorld" setup_version="0.0.1"> | ||
</module> | ||
</config> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?php | ||
\Magento\Framework\Component\ComponentRegistrar::register( | ||
\Magento\Framework\Component\ComponentRegistrar::MODULE, | ||
'Mageplaza_HelloWorld', | ||
__DIR__ | ||
); |
6 changes: 6 additions & 0 deletions
6
code/Mageplaza/HelloWorld/view/frontend/layout/hellomageplaza_index_index.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?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"> | ||
<referenceContainer name="content"> | ||
<block class="Mageplaza\HelloWorld\Block\Index" name="hellomageplaza_index_index" template="Mageplaza_HelloWorld::index.phtml" /> | ||
</referenceContainer> | ||
</page> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<h2>Welcome to Mageplaza.com</h2> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters