0

I'm trying to create custom block to show some info on the page, but got some weird issue that this block not showing. Already broke my brain by trying to debug why. There are some code snippets: config.xml

<config>
<module>
    <Module_Design>
        <version>0.0.2</version>
    </Module_Design>
</module>
<global>
    <helpers>
        <module_design>
            <class>Module_Design_Helper</class>
        </module_design>
    </helpers>
    <models>
        <module_design>
            <class>Module_Design_Model</class>
        </module_design>
    </models>
    <blocks>
        <module_design>
            <class>Module_Design_Block</class>
        </module_design>
    </blocks>
</global>
<frontend>
    <layout>
        <updates>
            <module_design>
                <file>module/design.xml</file>
            </module_design>
        </updates>
    </layout>
</frontend>
<default>
    <module_design>
        <notification>
            <!-- Promotion bar -->
            <stickybanner_enabled>0</stickybanner_enabled>
            <stickybanner_position>top</stickybanner_position>
            <stickybanner_visibility>default</stickybanner_visibility>
            <stickybanner_sort_order>1</stickybanner_sort_order>

            <!-- Cookie Opt-In -->
            <cookie_optin_enabled>1</cookie_optin_enabled>
            <cookie_optin_position>top</cookie_optin_position>
            <cookie_optin_visibility>default</cookie_optin_visibility>
            <cookie_optin_lifetime>604800</cookie_optin_lifetime>
            <cookie_optin_sort_order>0</cookie_optin_sort_order>
        </notification>
    </module_design>
</default>

design.xml

<?xml version="1.0"?>
<layout version="0.1.0">
    <default>
        <reference name="after_body_start">
            <block type="core/text_list" name="design.notifications">
                <block type="module_design/notification_stickybanner" name="module_design_notification_stickybanner"
                       as="stickybanner" template="module/design/notification/stickybanner.phtml"/>
            </block>
        </reference>
    </default>
</layout>

Stickybanner.php

class Module_Design_Block_Notification_Stickybanner extends Module_Design_Block_Notification_Abstract
{
    ...

    /**
     * check, if the notification should be shown
     *
     * @return bool
     */
    public function isShown()
    {
        if (!parent::isEnabled()) {
            return false;
        }
        if ($this->isTypeDefault()) {
            return true;
        }
        if (Mage::getModel('core/cookie')->get($this->_cookieName)) {
            return false;
        }
        return true;
    }
    ...

template stickybanner.phtml

<?php
/* @var $this Module_Design_Block_Notification_Stickybanner */
if (!$this->isShown()) {
    return;
}
?>
0

Have you added your block type in backoffice System > Permissions > Blocks ?

Screenshot

update

There is a typo error in your config.xml file

<config>
    <module>
        <Module_Design>
            <version>0.0.2</version>
        </Module_Design>
    </module>

Should be...

<config>
    <modules>
        <Module_Design>
            <version>0.0.2</version>
        </Module_Design>
    </modules>
  • <system> <children> <config> <children> <module_design> <title>Module Design</title> </module_design> </children> </config> </children> </system> – Oleg May 22 '18 at 10:54
  • in adminhtm.xml you mean? – Oleg May 22 '18 at 10:54
  • I mean the backoffice section – Raul Sanchez May 22 '18 at 10:54
  • yes, I did it. Also I see all fields for it in backend and in database. – Oleg May 22 '18 at 10:56
  • 99% sure problem in layout. Even if I do simple die/alert it's still not shows on page – Oleg May 22 '18 at 10:58
0

design.xml

<?xml version="1.0"?>
<layout version="0.1.0">
    <default>
        <reference name="after_body_start">
            <block type="design/notification_stickybanner" name="module_design_notification_stickybanner" template="module/design/notification/stickybanner.phtml"/>
        </reference>
    </default>
</layout>

config.xml

<blocks>
    <design>
        <class>Module_Design_Block</class>
    <design>
</blocks>

after_body_start is already a structural block so your module_design_notification_stickybanner will be rendered automatically.

The stickybanner.phtml should be in : app/design/frontend/{package}/{theme}/template/module/design/notification/stickybanner.phtml

The design.xml should be in : app/design/frontend/{package}/{theme}/layout/module/design.xml

Update:

config.xml

<modules>
    <Module_Design>
        <version>0.0.2</version>
    </Module_Design>
</modules>

instead of

<module>
    <Module_Design>
        <version>0.0.2</version>
    </Module_Design>
</module>

Don't forget the module declaration:

app/etc/modules/Module_Design.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Module_Design>
            <active>true</active>
            <codePool>local</codePool>
        </Module_Design>
    </modules>
</config> 
  • tried your solution as well. Still not working – Oleg May 22 '18 at 12:12
  • look my update, did your module works ? if it doesn't work, please share your full module code with full path files – PЯINCƏ May 22 '18 at 12:38
  • my bet is the module is not being correctly loaded, agree – Raul Sanchez May 23 '18 at 15:09

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.