Installing Alan Storm’s LayoutViewer in Magento (works with 1.7!)

I use the debug toolbar but nothing beats Alan Storm’s configviewer and layoutviewer. Unfortunately the only archive of this on Alan’s site is missing a module config file to activate it. Below is a simple shell script to download, install and activate the LayoutViewer in any version of Magento. I can confirm it works flawlessly in Magento 1.7. If you’d like to manually install this module, read the “manual installation” section below.

Script

#!/bin/sh

#VIEWER_HTTP_DOWNLOAD="http://alanstorm.com/2005/projects/MagentoLayoutViewer.tar.gz"
VIEWER_HTTP_DOWNLOAD="http://biodegradablegeek.com/MagentoLayoutViewer.tar.gz"

# If in root, go to app/code/local
if [ -f "index.php" ]; then
    cd app/code/local;
fi

echo "Using curl to download Magento LayoutViewer"
curl -so - $VIEWER_HTTP_DOWNLOAD | tar xvzf -

echo "Writing app/etc/modules/ config file"
(
cat <<'ConfigFile'
<?php xml version="1.0"?>
<config>
<modules>
 <Alanstormdotcom_Layoutviewer>
   <active>true</active>
   <codePool>local</codePool>
 </Alanstormdotcom_Layoutviewer>
</modules>
</config>
ConfigFile
) > ../../etc/modules/Alanstormdotcom_Layoutviewer.xml

echo "Done. Visit any page with ?showLayout=page"

Save this to a file and run “sh” in your Magento root.

Manual Installation

Download the MagentoLayoutViewer and extract the Alanstormdotcom folder to [magento-root]/app/code/local/

Create a new config file in app/etc/modules/ named Alanstormdotcom_Layoutviewer.xml  and paste in it the following:

<?php xml version="1.0"?>
<config>
<modules>
 <Alanstormdotcom_Layoutviewer>
   <active>true</active>
   <codePool>local</codePool>
 </Alanstormdotcom_Layoutviewer>
</modules>
</config>

Done. See usage below.

Module Usage

Visit any URL with ?showLayout=page (or handle or package) to retrieve the layouts XML

The module also accepts a showLayoutFormat=text argument if you’d like plain text instead of XML.

Example: http://my-store.cxm/product/123?showLayout=page&showLayoutFormat=text

2 thoughts on “Installing Alan Storm’s LayoutViewer in Magento (works with 1.7!)”

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>