Inchoo’s Magento Developer Toolbar prototype

Featured Image

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.

23
Top

Enjoyed this post?

Subscribe to our RSS Feed, Follow us on Twitter and spread it to your friends!

Author

Branko is Inchoo's CTO with over 3 years of active / everyday full time Magento development.

Other posts from this author

Discussion 23 Comments

Add Comment
  1. Interesting, will surely help the debugging :-)

    Keep us posted.

  2. Wow – what a great tool for Magento Development. I can’t wait to see how it progresses!

  3. Jacob

    Neat idea. Thanks for sharing the code. :)

  4. sweet – great idea as usual

  5. This is a great idea.

    Would be great if you guys could put this on launchpad.net or google code or anywhere so that anyone can contribute to it.

    The 1st thing that comes in mind would be to extend this “toolbar” to use Zend_Wildfire and Zend_Log to write messages straight to Firebug.

  6. @Romeo Adrian Cioaba

    Excellent idea. Hopefully during this week I will have time to write the first working version. After which we can setup the project under Launchpad. During these days I was doing some “thinking” on what features to throw in… got several ideas so far. Using Zend_Wildfire cross my mind. I was thinking in terms of extending (overwriting) core Mage exception class so that besides regular work it does an output to FirePHP.

  7. amadex

    Hi! The idea is great, but when I click any of the options (after double checking that everything is placed like you instruct), it keeps giving me a 404 error…

  8. Craig

    amadex, that’s because this is basically a proof-of-concept. You shouldn’t be installing this. He posted it to show everyone that it can be done. He posted the code to show how it’s going to be done. It’s not intended to be used just yet.

  9. amadex

    The idea is so good that I couldn’t resist on trying to implement it… :) I hope Branko move on to a working version fast! Very good.

  10. Ian

    This looks extremely handy and would save so much time jumping about in the control panel. Has it made it to release level yet?

  11. Marcio

    Please Help me ?

    Im my Application ocurred error 404, in INCHOO TOOLBAR, how to resolve ?

    http://portal.cerebrum.com.br/magento/magento_shopping/index.php/inchoohints/index/index/hints/on/

    Files for this Module

    http://portal.cerebrum.com.br/_tmp/modulo_Inchoo.zip

  12. This is great! I’ve been thinking about building a toolbar just like this, but never got around to it. It would be nice if this toolbar would show up in the admin panel, and would allow you to turn on template/block hints in the admin. You can see a blog post I wrote about how to enable those hints in the admin panel: http://classyllama.com/enable-templateblock-hints-in-admin-panel/

  13. Hi Erik,

    That links seems to be broken, but this one works: http://classyllama.com/blog/enable-templateblock-hints-in-admin-panel/

  14. Sam

    If you’re using the sample data setup for developing, you can just go to the configuration in the admin, select the ‘French’ store for example, and set that to show path hints. Then just go between the English and French stores to enable/disable them. That’s how I do it, works fine.

  15. Leeburstroghm

    Ha, I was so excited I popped it in as well.
    And got 404 errors as well, I thought I did something wrong.. too funny, How nice this would be and what a help. oh well!

  16. just wondering …

    this is soooo close from your toolbar (even the code)…

    http://www.mage-world.com/magento-developer-toolbar

  17. @Bruno

    What exactly are you wondering? Implying I stole the code? This is my code! The http://www.mage-world.com stinks to me like Asia Connect guys… the one I wrote previously, the ones that steal other people code and articles.

  18. Hey Branko. I believe he was implying the opposite ;)

  19. @Tomislav & @Bruno

    In that case, my apologize Bruno. I am a bit sick of copycats like Asia Connect and all other fraud business.

    Here is a nice thread that describes the related MageWorld issues http://www.magentocommerce.com/boards/viewthread/53479/.

    I just cant grasp the fact that Varien allows them to be a member on the forum http://www.magentocommerce.com/boards/member/162353. Its more than obvious that that something is out of order. Their contact information are less then obscure.

  20. Hi Branko…

    Like Tomislav said and well, I was “wondering” exactly the opposite …

    It was so you could take measures like … humm, something that you could do was what NIck told Craig some time ago (I was one of proud user of tooltip until Craig had to shut down the project)

    more here: http://naspinski.net/post/Is-Nick-Stakenburg-bullying-his-open-source-competitor.aspx

    I do hate this, and I do hate your efforts to help us, merely developers on this nice platform that we call Magento, I do love your articles and they have helped me putting a nice Webshop up and running.

    My “wondering” was really to tell you (in a nice way) that your code had been stolen and you should do something regarding it :)

    still friends? ;-)

  21. @Bruno

    lol… sure :)

  22. Mage-World bring us many useful extensions. Branko, could you let me know which line of code of MW Developer Toolbar is of yours?

  23. @David

    Please read again both of my comments, http://inchoo.net/tools/inchoos-magento-developer-toolbar-prototype/#comment-3754 and http://inchoo.net/tools/inchoos-magento-developer-toolbar-prototype/#comment-3756. I never said they stole my code. I merely added side-by comment related to fraud business.

    It was not my intention to throw negative marketing at you guys/girls. All I know is that I expect to see a bit more info on about page like yours http://www.mage-world.com/about-us/ when I am planning to give someone my money over online purchase.

    Stuff like “Please notify us. We are professionals, we understand what the clients need and we will serve you in the shortest possible time with your maximum satisfaction.” do not give any real info. Who are “We”? real names, etc…

    Cheers.

Add Your Comment

Please wrap all source codes with [code][/code] tags.
Top