Skip to content

Commit

Permalink
Crear una vista
Browse files Browse the repository at this point in the history
Crearemos una vista para el Frontend haciendo sudo del modulo creado anteriormente en Pfay: f693d0c

1.- Creamos nuestra carpeta vista que contendrá nuestros layous y templates.
2.- traemos nuestro template:
	app/code/Pfay/Contacts/view/frontend/templates/test_index.phtml
3.- Creaos nuestro Layout
	app/code/Pfay/Contacts/view/frontend/layout/contacts_test_index.xml

	OJO EL NOMBRE DEL ARCHIVO ESTARÁ COMPUESTO DE LA SIGUIENTE MANERA :
	'<id_of_the_route>_<name_of_the_controller>_<name_of_the_action>

4.- Modificamos nuestro controlador index:
	Agregamos la linea  para cargar el layout : ->_view->loadLayout();
	Agregamos la linea  para renderizarla : ->_view->renderLayout();
5.- Compilamos y re asignamos permisos
	php bin/magento setup:di:compile
	chmod -R 777 var/ pub/

6.- Verificamos cambios con la siguiente url :
	http://magento240.local/contacts/test/index
  • Loading branch information
PerezContrerasLuis committed Jan 19, 2022
1 parent f693d0c commit 45789fd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion code/Pfay/Contacts/Controller/Test/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class Index extends \Magento\Framework\App\Action\Action
{
public function execute()
{
die('test index');
$this->_view->loadLayout();
$this->_view->renderLayout();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?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">
<body>
<referenceContainer name="content">
<block class="Magento\Framework\View\Element\Template" name="contactForm" template="Pfay_Contacts::test_index.phtml"></block>
</referenceContainer>
</body>
</page>
3 changes: 3 additions & 0 deletions code/Pfay/Contacts/view/frontend/templates/test_index.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div id="contactslist">
my contact list
</div>

0 comments on commit 45789fd

Please sign in to comment.