how to call block method from magento 1 template

rra*_*iii 5 php xml templates magento

I'm new to magento and always have issues.

For now, I managed to add subscribe popup message and want to add a child block to my main block.

Code:(my custom module is My_Module)

<reference name="before_body_end">
    <block type="newsletter/subscribe" name="newsletter_popup" as="newsletter_popup" template="popup/subscribe.phtml">
        <block type="Module/popup_newsletter" name="newsletter11" />
    </block>
</reference name="before_body_end">
Run Code Online (Sandbox Code Playgroud)

and in subscribe.phtml I try the following:

var_dump($this->getChildHtml('newsletter11'))
Run Code Online (Sandbox Code Playgroud)

but the result is:

string(0)""

I tried to load the block from template in this way also:

var_dump($this->getLayout()->createBlock('module/popup_newsletter'));
Run Code Online (Sandbox Code Playgroud)

but the result is boolean(false).

what I want to do is call a method from child block (Newsletter.php) and this out put some text, this block for now has these two methods:

puplic function test(){
    return 'this is test';
}

public function _toHtml()
{
    return test();
}
Run Code Online (Sandbox Code Playgroud)

I can't see were is my mistake.

Can any one help me thankfully, I don't know if you need more code to post. Just let me know if you need

Thanks in advance.

update: config.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <modules>
        <My_Module>
            <version>1.0.1</version>
        </My_Module>
    </modules>

    <global>
        <models>
            <my_module>
                <class>My_Module_Model</class>
            </my_module>
        </models>
        <helpers>
            <my_module>
                <class>My_Module_Helper</class>
            </my_module>
        </helpers>
        <blocks>
            <my_module>
                <class>My_Module_Block</class>
            </my_module>
        </blocks>
    </global>
<frontend>
    <routers>
        <My_Module>
            <use>standard</use>
            <args>
                <module>My_Module</module>
                <frontName>my</frontName>
            </args>
        </My_Module>
    </routers>
    </frontend>
Run Code Online (Sandbox Code Playgroud)

Mee*_*m R 3

在模板 (phmtl) 文件中为块创建对象。尝试下面的代码

$customBlock = $this->getLayout()->getBlock('block_name'); // You can use newsletter11 in that block_name
Run Code Online (Sandbox Code Playgroud)

调用块函数

echo $customBlock->test();
Run Code Online (Sandbox Code Playgroud)