Skip to content

Commit

Permalink
Creacion de controlador que extiende template
Browse files Browse the repository at this point in the history
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
PerezContrerasLuis committed Jan 15, 2022
1 parent 106a361 commit da84932
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 0 deletions.
Binary file added code/.DS_Store
Binary file not shown.
Binary file added code/Luisdev/.DS_Store
Binary file not shown.
Binary file added code/Luisdev/Helloworld/.DS_Store
Binary file not shown.
5 changes: 5 additions & 0 deletions code/Luisdev/Helloworld/Block/Index.php
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
{
}
18 changes: 18 additions & 0 deletions code/Luisdev/Helloworld/Controller/Index/Index.php
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 added code/Luisdev/Helloworld/view/.DS_Store
Binary file not shown.
Binary file not shown.
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>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<h1>This is my first template</h1>

0 comments on commit da84932

Please sign in to comment.