1

I'm building a module in Magento, the frontend is all setup and working and now I've got to add a page to the Adminhtml area (Which I've done).

The issue I'm having is that I've got my Block (Namespace_Name_Block), which is all referenced in the section of my modules config.xml:

     <global>
        .....
        <blocks>
            <veridial>
                <class>Liquid11_Veridial_Block</class>
            </veridial>
        </blocks>
        .....
        </global>

Inside here I've got a function

    public function getVeridialBaseUrl(){
        // Do Something
    }

Now, this function is working fine on my Frontend page with the following code:

<?php echo $this->getVeridialBaseUrl(); ?>

However, when I use this same code on my page within the /admin section it's not working and there's nothing in my log files from this. Do I need to add some additional code, or an extra block for the Adminhtml section?

3 Answers 3

1

You didn't show much code so I'm just guessing that you didn't add your xml in the admin section. You probably have this for frontend in config.xml:

<frontend>
    <layout>
        <updates>
            <veridial>
                <file>veridial.xml</file>
            </veridial>
        </updates>
    </layout>
</frontend>

You need this one for admin section:

<adminhtml>
    <layout>
        <updates>
            <veridial>
                <file>veridial.xml</file>
            </veridial>
        </updates>
    </layout>
</adminhtml>
1
  • Sorry, didn't want to paste all the code and bloat the question. I've got the code above in my config.xml file Aug 4, 2015 at 9:50
1

I've resolved this issue by using the following code:

Mage::getBlockSingleton('veridial/veridial');
1

Did you try to put the block class inside an Adminhtml folder?

Then the class name would be Liquid11_Veridial_Block_Adminhtml_Veridial

So you can call your block in layout file as belows.

<block type="veridial/adminhtml_veridial" name="custom.name" template="path/to/your/template.phtml" />

Now inside your .phtml file if you call any function (which resides in the block class,) it should work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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