I'm very new to magento development. I got stuck on creating a template or block extension that shows some php on every single page if you're logged in and an admin.

I got the block working (I think) and i make a test.php page to test it and it worked fine.

My blockdesign.php file:

class McDefault_locationreminder_Block_Blockdesign{
    private $content;
    private $loco;

    public function __construct(){
        $this->content = $_SERVER['SERVER_ADDR'];
        $this->loco = 'local';//TODO: Fetch from db

    public function showBlock(){
        echo '<div class="reminder">'.$this->loco.': '.$this->content.'</button></div>';

The test.php file:


require_once 'app/Mage.php';


$product = new McDefault_locationreminder_Block_Blockdesign;

a busy cat

Now the only part is to made it a template and show on all pages (as admin).

This is where i need help because i have no clue on where to create all these xml files or phtml files.

I need help with the path to create these files and the content of them. namespace is McDefault and name is locationreminder.


This is not the proper way of creating a block in magento. The right way is the "module" way and you can find an example here.

If you want to see the block which is creating by the above module in every page, then you need to do a small modification in the below file

File : app\design\frontend\base\default\layout\rkt_customblock.xml

        <reference name="content">
            <block type="rkt_customblock/helloworld" name="myblock.helloworld" template="rkt_customblock/helloworld.phtml" />

It is very important understand the "flow" that happens here. Unfortunately it is too broad to explain here. There are lot of tutorials available for this. However you can use this one to get an idea.

Hope that helps.

  • Thank you for your response. I will check your links out. – Max O. Dec 28 '15 at 9:28
  • I got most of it working, except for one thing. The block displays on only the frontend. I'd like it to show in the admin panel too. Any idea how that is done? – Max O. Dec 28 '15 at 10:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.