├── README.md
├── app
├── code
│ └── local
│ │ └── Alanstormdotcom
│ │ └── Layoutviewer
│ │ ├── Model
│ │ ├── Layout
│ │ │ └── Update.php
│ │ └── Observer.php
│ │ └── etc
│ │ └── config.xml
└── etc
│ └── modules
│ └── Alanstormdotcom_Layoutviewer.xml
├── build_layout_viewer.bash
├── composer.json
└── modman
/README.md:
--------------------------------------------------------------------------------
1 | LayoutViewer
2 | ============
3 |
4 | A Magento module that dumps layout information via query string.
5 |
6 | This extension's functionality has been supplanted by Commerce Bug, but it's kept here for historical and educational purposes.
7 |
8 | ###Layout Viewer
9 |
10 | Implements a query string based way to view layout information for a particular request.
11 |
12 | Original Blog Post: http://alanstorm.com/layouts_blocks_and_templates
13 |
14 | ###Build Instructions
15 |
16 | The `build_layout_viewer.bash` file is a bash script that will create a simple tar archive of the extension files.
17 |
18 | $ ./build_layout_viewer.bash
19 |
20 | This script assumes the existence of a `var` folder.
--------------------------------------------------------------------------------
/app/code/local/Alanstormdotcom/Layoutviewer/Model/Layout/Update.php:
--------------------------------------------------------------------------------
1 | fetchFileLayoutUpdates();
33 | return $this->_packageLayout;
34 | }
35 | }
--------------------------------------------------------------------------------
/app/code/local/Alanstormdotcom/Layoutviewer/Model/Observer.php:
--------------------------------------------------------------------------------
1 | setLayout(Mage::app()->getFrontController()->getAction()->getLayout());
36 | $this->setUpdate($this->getLayout()->getUpdate());
37 | }
38 |
39 | //entry point
40 | public function checkForLayoutDisplayRequest($observer) {
41 | $this->init();
42 | /** @var Mage_Core_Controller_Varien_Action $controllerAction */
43 | $controllerAction = $observer->getEvent()->getData('controller_action');
44 | if ($controllerAction->getRequest()->isDispatched()) {
45 | $is_set = array_key_exists(self::FLAG_SHOW_LAYOUT, $_GET);
46 | if( $is_set && 'package' == $_GET[self::FLAG_SHOW_LAYOUT]) {
47 | $this->outputPackageLayout();
48 | }
49 | else if($is_set && 'page' == $_GET[self::FLAG_SHOW_LAYOUT]) {
50 | $this->outputPageLayout();
51 | }
52 | else if($is_set && 'handles' == $_GET[self::FLAG_SHOW_LAYOUT]) {
53 | $this->outputHandles();
54 | }
55 | }
56 | }
57 |
58 | private function outputHandles() {
59 | $update = $this->getUpdate();
60 | $handles = $update->getHandles();
61 | echo '
','Handles For This Request','
'."\n";
62 | echo '' . "\n";
63 | foreach($handles as $handle) {
64 | echo '- ',$handle,'
';
65 | }
66 | echo '
' . "\n";
67 | die();
68 | }
69 |
70 | private function outputHeaders() {
71 | $is_set = array_key_exists(self::FLAG_SHOW_LAYOUT_FORMAT,$_GET);
72 | $header = self::HTTP_HEADER_XML;
73 | if($is_set && 'text' == $_GET[self::FLAG_SHOW_LAYOUT_FORMAT]) {
74 | $header = self::HTTP_HEADER_TEXT;
75 | }
76 | header($header);
77 | }
78 |
79 | private function outputPageLayout() {
80 | $layout = $this->getLayout();
81 | $this->outputHeaders();
82 | die($layout->getNode()->asXML());
83 | }
84 |
85 | private function outputPackageLayout() {
86 | $update = $this->getUpdate();
87 | $this->outputHeaders();
88 | die($update->getPackageLayout()->asXML());
89 | }
90 | }
--------------------------------------------------------------------------------
/app/code/local/Alanstormdotcom/Layoutviewer/etc/config.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 0.1.0
6 |
7 |
8 |
9 |
10 |
11 | Alanstormdotcom_Layoutviewer_Model
12 |
13 |
14 |
15 |
16 | Alanstormdotcom_Layoutviewer_Model_Layout_Update
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 | singleton
27 | Alanstormdotcom_Layoutviewer_Model_Observer
28 | checkForLayoutDisplayRequest
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/app/etc/modules/Alanstormdotcom_Layoutviewer.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | false
6 | local
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/build_layout_viewer.bash:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | mkdir var/build
4 |
5 | #OS X, prevent ._ files
6 | export COPYFILE_DISABLE=true
7 | tar -cvf var/build/Layout_Viewer.tar app/code/local/Alanstormdotcom/Layoutviewer app/etc/modules/Alanstormdotcom_Layoutviewer.xml
8 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name" : "pulsestorm/layoutviewer",
3 | "type" : "magento-module",
4 | "description" : "A Magento module that dumps layout information via query string.",
5 | "version" : "0.1.0",
6 | "keywords" : ["magento","blocks","layout"],
7 | "license" : "MIT",
8 | "homepage" : "http://alanstorm.com/layouts_blocks_and_templates",
9 |
10 | "authors": [
11 | {
12 | "name" : "Alan Storm",
13 | "email" : "alanstorm@alanstorm.com",
14 | "homepage": "http://alanstorm.com",
15 | "role": "developer"
16 | }
17 | ],
18 | "require": {
19 | "php": ">=5.2.0",
20 | "magento-hackathon/magento-composer-installer": "*"
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/modman:
--------------------------------------------------------------------------------
1 | app/code/local/Alanstormdotcom/Layoutviewer/ app/code/local/Alanstormdotcom/Layoutviewer/
2 | app/etc/modules/Alanstormdotcom_Layoutviewer.xml app/etc/modules/Alanstormdotcom_Layoutviewer.xml
3 |
--------------------------------------------------------------------------------