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;nbsp;&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;nbsp;&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;nbsp;&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 comments

  1. @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.

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

  3. 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? πŸ˜‰

  4. @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.

  5. 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!

  6. 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.

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

  8. 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.

  9. 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.

  10. 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…

  11. @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.

  12. 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.

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=""> <blockquote cite=""> <code> <del datetime=""> <em> <s> <strike> <strong>. You may use following syntax for source code: <pre><code>$current = "Inchoo";</code></pre>.