Inchoo’s Magento Developer Toolbar prototype

23 Comments 23rd JUL 2009 | Posted by Branko Ajzele in Magento, Tools

Inchoo’s Magento Developer Toolbar prototype

I was playing with some of the Magento controller functions today, when I saw my coworker Vedran Subotic struggling with turning the Path hints in On and Off every few minutes. Idea cross my mind, and here is the result Inchoo’s Magento Developer Toolbar prototype.

Here is the sample screenshot of the toolbar. Note that this is not even a developer draft version :) Work in progress :)

InchooMagentoToolbarPreview

And here is the code for the toolbars app/code/local/Inchoo/Hints/controllers/IndexController.php file

< ?php

class Inchoo_Hints_IndexController extends Mage_Core_Controller_Front_Action
{

public function init()
{

}

public function indexAction()
{
$hints = $this->getRequest()->getParam('hints');

$_db = Mage::getSingleton('core/resource')->getConnection('core_write');

if($hints)
{
if($hints == 'on')
{
$_db->query("UPDATE core_config_data SET value = '".$_SERVER['REMOTE_ADDR']."' WHERE path = 'dev/restrict/allow_ips'; ");
$_db->query("UPDATE core_config_data SET value = 1 WHERE path = 'dev/debug/template_hints';");
$_db->query("UPDATE core_config_data SET value = 1 WHERE path = 'dev/debug/template_hints_blocks'; ");
}

if($hints == 'off')
{
$_db->query("UPDATE core_config_data SET value = '' WHERE path = 'dev/restrict/allow_ips'; ");
$_db->query("UPDATE core_config_data SET value = 0 WHERE path = 'dev/debug/template_hints';");
$_db->query("UPDATE core_config_data SET value = 0 WHERE path = 'dev/debug/template_hints_blocks'; ");
}
}

$_url = Mage::getUrl('');

if(isset($_SERVER['HTTP_REFERER'])) $_url = $_SERVER['HTTP_REFERER'];

$this->getResponse()->setRedirect($_url);
}

public function cleanCacheAction()
{
$_url = Mage::getUrl('');

if(isset($_SERVER['HTTP_REFERER'])) $_url = $_SERVER['HTTP_REFERER'];

Mage::app()->cleanCache();

$this->getResponse()->setRedirect($_url);
}

public function cleanPhotoCacheAction()
{
$_url = Mage::getUrl('');

if(isset($_SERVER['HTTP_REFERER'])) $_url = $_SERVER['HTTP_REFERER'];

try {
Mage::getModel('catalog/product_image')->clearCache();
}
catch (Exception $e) { }

$this->getResponse()->setRedirect($_url);
}
}

And the stuff I put under top of the app/design/frontend/default/default/template/page/html/header.phtml file:

< ?php //START INCHOO DEVELOPER TOOLBAR ?>

< ?php
$_inchoo_db = Mage::getSingleton('core/resource')->getConnection('core_write');
$hints_are_on = $_inchoo_db->fetchOne("SELECT value FROM core_config_data WHERE path = 'dev/debug/template_hints'");
?>

<div style="line-height: 24px; font-size: 10px; font-family: Arial, Verdana; background: #004400; border-bottom:solid 1px white; color: White; margin-top: -5px;">
<div>
<span style="font-weight: bold; margin-right: 10px; margin-left: 10px;">INCHOO TOOLBAR</span>
< ?php if($hints_are_on): ?>
<a style="text-decoration: none; color: #bbbbbb;" href="<?php echo $this->getUrl('inchoohints/index/index/hints/off') ?>">HINTS OFF</a>&amp;amp;amp;nbsp;&amp;amp;amp;nbsp;
< ?php else: ?>
<a style="text-decoration: none; color: #bbbbbb;" href="<?php echo $this->getUrl('inchoohints/index/index/hints/on') ?>">HINTS ON</a>&amp;amp;amp;nbsp;&amp;amp;amp;nbsp;
< ?php endif; ?>

<a style="text-decoration: none; color: #bbbbbb;" href="<?php echo $this->getUrl('inchoohints/index/cleanCache') ?>">CLEAN CACHE</a>&amp;amp;amp;nbsp;&amp;amp;amp;nbsp;
<a style="text-decoration: none; color: #bbbbbb;" href="<?php echo $this->getUrl('inchoohints/index/cleanPhotoCache') ?>">CLEAN IMAGE CACHE</a>
</div>
</div>
< ?php //END INCHOO DEVELOPER TOOLBAR ?>

Module app/code/local/Inchoo/Hints/etc/config.xml file:

< ?xml version="1.0"?>
<config>
<modules>
<inchoo_hints>
<version>1.0.0</version>
</inchoo_hints>
</modules>
<frontend>
<routers>
<ihints>
<use>standard</use>
<args>
<module>Inchoo_Hints</module>
<frontname>inchoohints</frontname>
</args>
</ihints>
</routers>
</frontend>
</config>

And finally app/etc/modules/Inchoo_Hints.xml file content:

< ?xml version="1.0"?>

<config>
<modules>
<inchoo_hints>
<active>true</active>
<codepool>local</codepool>
</inchoo_hints>
</modules>
</config>

Note that this is merely an overview. Work in progress :)

Cheers.

If you like what you read, please share it.

  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Yahoo! Bookmarks
  • Reddit
  • Technorati
  • Twitter
  • StumbleUpon
  • LinkedIn
  • Netvibes
  • NewsVine
  • Sphinn
  • Tumblr
  • Posterous

To post code in comments, place your code inside [code] and [/code] tags.

There are 23 comments (Add Yours +)

Leave a Comment

Please wrap all source codes with [code][/code] tags.
Magento Design and Development | Magento SEO | iPhone Application Development Web Application Development with ZEND | WordPress Ecommerce | WordPress development
Sitemap

Inchoo - webappsolutions | 2009