1

I made a module and with in it a Block. I am trying to pull it into the home page by entering this into the editor for home page CMS page editor:

{{block type="thinkopen/overwriter" block_id="Categoriesmenu" name="Categoriesmenu" template="thinkopen_overwriter/categoriesmenu.phtml"}}  

Somehow, I am not getting the results. Can you tell me what am I missing here? Things I did:
-My Thinkopen/Overwriter/etc/config.xml module config file is:

<config>
    <modules>
        <Thinkopen_Overwriter>
            <version>2.0.0.1</version>
        </Thinkopen_Overwriter>
    </modules>
    <global>
        <blocks>
            <overwriter>
                <class>Thinkopen_Overwriter_Block</class>
            </overwriter>
        </blocks>
    </global>
</config>

-My Block is defined in Block/Categoriesmenu.php as so:

<?php

class Thinkopen_Overwriter_Block_Categoriesmenu extends Mage_Core_Block_Template
{

    public function _construct()
    {

        return parent::_construct();
    }

    public function _beforeToHtml()
    {
        echo "Categories_Menu from my module";
    }

}
?>

-My cache is disabled and cleared.

| improve this question | | | | |
1

You need to change your config.xml file like this:

<config>
    <modules>
        <Thinkopen_Overwriter>
            <version>2.0.0.1</version>
        </Thinkopen_Overwriter>
    </modules>
    <global>
        <blocks>
            <thinkopen_overwriter>
                <class>Thinkopen_Overwriter_Block</class>
            </thinkopen_overwriter>
        </blocks>
    </global>
</config>

Secondly, you need to change your block directive like this:

{{block type="thinkopen_overwriter/categoriesMenu" block_id="CategoriesMenu" name="CategoriesMenu"}} 

Thirdly, you need to whitelist your block type if you are using a Magento version >= 1.9.0. For this, you can go to System > Permissions > Blocks in admin side and add your block type thinkopen_overwriter/categoriesMenu there.

EDIT

In order to check whether your block directive works, you need to change your block directive like this.

{{block type="thinkopen_overwriter/categoriesMenu" template="thinkopen_overwriter/categorymenu.phtml"}} 

Now create your phtml file at app\design\frontend\base\default\template\thinkopen_overwriter/categorymenu.phtml. It's content should be:

<p><?php echo "Categories_Menu from my module"; ?></p>
| improve this answer | | | | |
  • Hi, @Rajeev, I modified everything as you said - I corrected the config.xml, whitelisted the block and added the directive as you said - and result is the same. My output from the block is not showing on home page. – Vladimir Despotovic Nov 2 '16 at 16:16
  • That is because your block is doing nothing. _beforeHtml() wont work in your case. – Rajeev K Tomy Nov 2 '16 at 16:18
  • I added _toHtml() { echo "Hi from CategoriesMenu"; } method to the Block class but it is still not showing. Also, I can't see my block in template hints. – Vladimir Despotovic Nov 2 '16 at 16:21
  • see my edit and make sure you cleared all cache. – Rajeev K Tomy Nov 2 '16 at 16:22
  • I mentioned the path in my answer itself. Please read it carefully. – Rajeev K Tomy Nov 2 '16 at 16:24
0

I resolved the issue by setting chmod 777 to every file in Magento.

| improve this answer | | | | |
  • this could lead to a lot of problems if you deploy this code live. if the web server can hit every file in your magento install, your db creds will be out in the open and you will get hacked 100% of the time. – circlesix Nov 2 '16 at 22:45
  • off course. I suppose you have a better solution then? – Vladimir Despotovic Nov 2 '16 at 22:46
  • if file permissions is the issue, rest the whole site following this link: devdocs.magento.com/guides/m1x/install/…. From there you can test again. – circlesix Nov 2 '16 at 22:49
  • Thanks for that. However, I am almost 100% sure that the problem was the permission level on some files/directories. This was my problem as states the question! Keep the trolling on the minimum, please. Thank you. – Vladimir Despotovic Nov 2 '16 at 23:04
  • 1
    Glad to see that you made it finally. However please take into consideration about @circlesix's point. Donot give 777 permission to all directories – Rajeev K Tomy Nov 3 '16 at 12:20

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.