-
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.
Creacion de controlador que extiende template
1.- Creamos controlador Index 2.- creamos LAYOUT ( este conecta el block y el temmplate) importante: el nombre del archivo tiene que ser el mismoque se uso en el atributo name 3.- cramos el block 4.- creamos nuestro template index.phtml 5.- nuevamente compilamos : php bin/magento setup:upgrade 6.- si no carga los templates podemos crear archivos staticos y compilar y dar permisos nuevamente php bin/magento setup:upgrade php bin/magento setup:static-content:deploy -f chmod -R 777 var/ pub/
- Loading branch information
1 parent
106a361
commit da84932
Showing
9 changed files
with
30 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
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 @@ | ||
<?php | ||
namespace Luisdev\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,18 @@ | ||
<?php | ||
namespace Luisdev\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(); | ||
//echo "Controlador index sin page Favtory"; | ||
} | ||
} |
Binary file not shown.
Binary file not shown.
6 changes: 6 additions & 0 deletions
6
code/Luisdev/Helloworld/view/frontend/layout/helloworld_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="Luisdev\Helloworld\Block\Index" name="helloworld_index_index" template="Luisdev_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 @@ | ||
<h1>This is my first template</h1> |