Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Blocks are not render from a controller action
 
Huberto
Jr. Member
 
Avatar
Total Posts:  6
Joined:  2007-11-14
Porto Alegre
 

Hi,
I have a dificulty for make a payment module.
I studied other Mage_ modules, and, apparently, is everything ok.
The module is on community, the Company name is Verborum and module name is Verpay - app/code/community/Verborum/Verpay
Have a Controller named BoletoController.php and action named redirectAction, this result on a url:
http://www.sitename.com/verpay/boleto/redirect
Have a block Redirect and your template.

I will place the relevant codes below.

controller/BoletoController.php :

class Verborum_Verpay_BoletoController extends Mage_Core_Controller_Front_Action
{

...
    public function 
redirectAction()
    
{
        $this
->loadLayout();
        
$this->renderLayout();
    
}
...

Block/boleto/Redirect.php :

class Verborum_Verpay_Block_Boleto_Redirect extends Mage_Core_Block_Abstract
{


    
protected function _construct()
    
{
        $this
->setTemplate('verpay/boleto/redirect.phtml');
        
parent::_construct();
    
}

    
    
public function getForm()
    
{
        
    $boleto 
Mage::getModel('verpay/method_boleto');

        
$form = new Varien_Data_Form();
        
$form->setAction($boleto->getVerpayUrl())
            ->
setId('verpay_checkout')
            ->
setName('verpay_checkout')
            ->
setMethod('POST')
            ->
setUseContainer(true);
        foreach (
$boleto->getBoletoCheckoutFormFields() as $field=>$value{
            $form
->addField($field'hidden', array('name'=>$field'value'=>$value));
        
}

       
return $form->toHtml();
    
}

}

app/design/frontend/default/default/layout/verpay.xml :

<layout version="0.1.0">

    <
verpay_boleto_redirect>
        <!--
remove name="left"/-->

        <
reference name="root">
            <
action method="setTemplate"><template>page/2columns-right.phtml</template></action>
        </
reference>

        <
reference name="content">
            <
block type="verpay/boleto_redirect" name="verpay.boleto.redirect" output="toHtml" as="verpay-boleto-redirect" template="verpay/boleto/redirect.phtml"/>
        </
reference>
    </
verpay_boleto_redirect>


</
layout>

app/design/frontend/default/default/template/verpay/boleto/redirect.phtml

<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>

<?php 
echo $this->__('You will be redirected to Boleto Bancario da Verpay in a few seconds.'?>
<br/>

<?php echo $this->getForm() ?>

<script type="text/javascript">
    
document.getElementById("verpay_checkout").submit();
</script>

The result is a default 2 columns whitout block verpay/boleto_redirec render in content area.
I clean var/cache in every change in code.

I include te actual module code in this post, for total vision of the code.

Someone help me?
Tanks!

 
Magento Community Magento Community
Magento Community
Magento Community
 
L1234
Jr. Member
 
Total Posts:  8
Joined:  2009-05-11
 

Hi Huberto,

did you find a solution for this?

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top