Skip to content

Commit

Permalink
feat: Creating Frontend Layouts
Browse files Browse the repository at this point in the history
  • Loading branch information
HDTran committed Apr 9, 2019
1 parent 42f71a3 commit c3b0511
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ class MasteringMagento_Example_IndexController extends Mage_Core_Controller_Fron
{
public function indexAction()
{
echo 'Hello, World! I am in the index!';
$this->loadLayout();

return $this->renderLayout();
}
}

Expand Down
7 changes: 7 additions & 0 deletions app/code/local/MasteringMagento/Example/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,12 @@
</args>
</example>
</routers>
<layout>
<updates>
<example>
<file>example.xml</file>
</example>
</updates>
</layout>
</frontend>
</config>
20 changes: 20 additions & 0 deletions app/design/frontend/base/default/layout/example.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0"?>
<!DOCTYPE layout>
<!--
/**
* app/design/frontend/base/default/layout/example.xml
*
* This example code is provided for use with the Mastering Magento video
* series, by Packt Publishing.
*
* @author Franklin P. Strube <franklin.strube@gmail.com>
* @category MasteringMagento
* @package Example
* @copyright Copyright (c) 2012 Packt Publishing (http://packtpub.com)
*/
-->
<layout version="0.1.0">
<example_index_index>
<update handle="page_two_columns_right" />
</example_index_index>
</layout>

1 comment on commit c3b0511

@HDTran
Copy link
Owner Author

@HDTran HDTran commented on c3b0511 Apr 23, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2.8 Recap: Creating Frontend Layouts

A layout is a special type of file that is part of the Magento View Layer. The XML syntax determines which components will be visible on the Magento page.

Modify config.xml

Added <layout> snippet in the <frontend> section to define a new layout file: example.xml.

Created Layout File

We created the associated example.xml layout file in app/design/frontend/base/default/layout/example.xml.

Modify Controllers

We then had to modify the controllers to use the layout file and render the layout file by using $this->loadLayout() and $this->renderLayout().

Please sign in to comment.