Skip to main content
added 3 characters in body
Source Link
Kishor Thummar
  • 3k
  • 1
  • 11
  • 19

thisThis is a simple Hello worldWorld in a Block, iI would like how can iI get the URL of this, to check in the website this HelloWorld.

I don't know to check my exercises, beacuse ibecause I don't know how to get the urlURL to put in my

I'm starting in the world of magento, and i'mI'm doing severalsseveral exercises.

\home\cloudpanel\htdocs\magento2.mgt\app\code\Unit3\HelloWorldBlock\Controller\Block\Index.php

<?php namespace Unit3\HelloWorldBlock\Controller\Block; 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; parent::__construct($context); } public function execute() { $layout = $this->_pageFactory->create()->getLayout(); $block = $layout->createBlock('Unit3\HelloWorldBlock\Block\Test'); $result = $this->resultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_RAW); $result->setContents($block->toHtml()); return $result; } } 

\home\cloudpanel\htdocs\magento2.mgt\app\code\Unit3\HelloWorldBlock\etc\frontend\routes.xml

<?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 id="unit3helloworldblock" frontName="unit3helloworldblock"> <module name="Unit3_HelloWorldBlock" /> </route> </router> </config> 

the result every time is this: enter image description here

THANKS

this is a simple Hello world in a Block, i would like how can i get the URL of this, to check in the website this HelloWorld.

I don't know check my exercises, beacuse i don't know how to get the url to put in my

I'm starting in world of magento, and i'm doing severals exercises.

\home\cloudpanel\htdocs\magento2.mgt\app\code\Unit3\HelloWorldBlock\Controller\Block\Index.php

<?php namespace Unit3\HelloWorldBlock\Controller\Block; 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; parent::__construct($context); } public function execute() { $layout = $this->_pageFactory->create()->getLayout(); $block = $layout->createBlock('Unit3\HelloWorldBlock\Block\Test'); $result = $this->resultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_RAW); $result->setContents($block->toHtml()); return $result; } } 

\home\cloudpanel\htdocs\magento2.mgt\app\code\Unit3\HelloWorldBlock\etc\frontend\routes.xml

<?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 id="unit3helloworldblock" frontName="unit3helloworldblock"> <module name="Unit3_HelloWorldBlock" /> </route> </router> </config> 

the result every time is this: enter image description here

THANKS

This is a simple Hello World in a Block, I would like how can I get the URL of this, to check the website this HelloWorld.

I don't know to check my exercises, because I don't know how to get the URL to put in my

I'm starting in the world of magento, and I'm doing several exercises.

\home\cloudpanel\htdocs\magento2.mgt\app\code\Unit3\HelloWorldBlock\Controller\Block\Index.php

<?php namespace Unit3\HelloWorldBlock\Controller\Block; 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; parent::__construct($context); } public function execute() { $layout = $this->_pageFactory->create()->getLayout(); $block = $layout->createBlock('Unit3\HelloWorldBlock\Block\Test'); $result = $this->resultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_RAW); $result->setContents($block->toHtml()); return $result; } } 

\home\cloudpanel\htdocs\magento2.mgt\app\code\Unit3\HelloWorldBlock\etc\frontend\routes.xml

<?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 id="unit3helloworldblock" frontName="unit3helloworldblock"> <module name="Unit3_HelloWorldBlock" /> </route> </router> </config> 

the result every time is this: enter image description here

THANKS

Source Link

How can I get the url of my new module?

this is a simple Hello world in a Block, i would like how can i get the URL of this, to check in the website this HelloWorld.

I don't know check my exercises, beacuse i don't know how to get the url to put in my

I'm starting in world of magento, and i'm doing severals exercises.

\home\cloudpanel\htdocs\magento2.mgt\app\code\Unit3\HelloWorldBlock\Controller\Block\Index.php

<?php namespace Unit3\HelloWorldBlock\Controller\Block; 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; parent::__construct($context); } public function execute() { $layout = $this->_pageFactory->create()->getLayout(); $block = $layout->createBlock('Unit3\HelloWorldBlock\Block\Test'); $result = $this->resultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_RAW); $result->setContents($block->toHtml()); return $result; } } 

\home\cloudpanel\htdocs\magento2.mgt\app\code\Unit3\HelloWorldBlock\etc\frontend\routes.xml

<?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 id="unit3helloworldblock" frontName="unit3helloworldblock"> <module name="Unit3_HelloWorldBlock" /> </route> </router> </config> 

the result every time is this: enter image description here

THANKS