English 中文(简体)
Magento: 如何通过编码将链接添加到习惯单元的一组中?
原标题:Magento: how to add a link via code to a block of a custom module?

我试图把我的一个区块连接到我的控制员的具体行动上。 看一看docs子和羊.,就能够解决一些有益的问题。 (也许我只是使用错误的查询)。

我的主计长采取了两项行动:

行动和出口行动指数

现在,在我的一个区块中,我与出口行动挂钩。 我发现,这种方法增加了链接,但这只是t工作。

是否有任何人知道如何这样做? 还是可以把适当的资源放在净额上?

关于Alex

例:

<?php

class Polyvision_Tempest_Block_Adminhtml_View extends Mage_Adminhtml_Block_Template
{
    public function __construct()
    {
        parent::__construct();
    }

    protected function _toHtml()
    {

    $html = "whatever";

        return $html;
    }
}
?>
最佳回答

你的问题不明确。

一部分通过phtml模板或通过PHP代码提供超文本。 为了添加一个超文本链接,你只是把一个html子的html锁放在了一边。

//via PHP
protected function _toHtml()
{
    $html =  <a href="<?php echo $this->url( frontname/controllername/action/key/value/key/value );?>">My Link</a> ;
    return $html;
}     


//via phtml template

#your block
class Polyvision_Tempest_Block_Adminhtml_View extends Mage_Adminhtml_Block_Template
{
    protected function _construct()
    {
        $this->setTemplate( path/to/from/template/folder/as/basetemplate.phtml );
    }
}

#your template
<a href="<?php echo $this->url( frontname/controllername/action/key/value/key/value );?>">My Link</a> ;

<代码>addLink方法是一种特殊方法,只适用于某些类型的区块。 当你打电话时,它将信息与块块数据特性联系起来。 之后,其“toHtml”方法或“phtml”模板已经写成,以便储存的数据与产出链接相左。 这并不适用于一般区块,这就是你的问题混淆。

希望帮助!

问题回答

暂无回答




相关问题
Working with modules in IntelliJ IDEA

As I understand, using modules allows us to control some dependencies. I mean that we can allow one module to interact with another one but not vise versa. We also can make some reusable things and ...

Module import path

I m unable to test-run a cssparser that I d like to use. test.py: from css.parse import parse data = """ em { padding: 2px; margin: 1em; border-width: medium; border-style: ...

Problem modulating action script project

I am refactoring a hugh action script solution in Flash builder (beta 2) using the flex 4 sdk. The project does NOT use the mx framework. What i want to have is: A big MAIN project several small ...

Test modules with Test::Unit

I encountered a problem when trying to test a module with Test::Unit. What I used to do is this: my_module.rb: class MyModule def my_func 5 # return some value end end test_my_module.rb: ...

Drupal section accessible by role

I need to limit access of content on Drupal site based on the Drupal User s Role. http://site.com/managers/intro http://site.com/managers/reviews http://site.com/managers/up-for-raises The ...

How to find where a function was imported from in Python?

I have a Python module with a function in it: == bar.py == def foo(): pass == EOF == And then I import it into the global namespace like so: from bar import * So now the function foo is ...

How to wire two modules in Verilog?

I have written two modules DLatch and RSLatch and i want to write verilog code to join those two.

热门标签