1

This is my code from my controller:

$block = $this->getLayout()
->createBlock('mynamespace_mymodule/adminhtml_pdf_invoice')
->setData('invoice', "mydata")
->setTemplate('mynamespace_mymodule/pdf/invoice.phtml');  

This is my block content:

class Mynamespace_Mymodule_Myblock_Block_Adminhtml_Pdf_Invoice extends Mage_Core_Block_Template
{
//methods
}

I am trying to get the value of a template and put the content in a pdf file using the toHtml function. In my case:

$block->toHtml()  

which is empty for some reason.

This is the path of my template:

.modman/Mynamespace_Mymodule/src/app/design/adminhtml/default/default/template/mynamespace_mymodule/pdf/invoice.phtml

My first thought was about the symlinks. There are enabled from system/configuration and the modman files are deployed.

Why the content of the toHtml function is empty ? What should I check more ?

Thx in advance !

[UPDATE] I make a var_dump($block). and this is part of it:

...
["_allowSymlinks":protected]=>
  NULL
  ["_template":protected]=>
  string(29) "mynamespace_mymodule/pdf/invoice.phtml"
.....

I'm not sure why the allowSymlinks has the value NULL.

1
  • pls check my answer and let me know if it works or not. Oct 21, 2016 at 8:17

1 Answer 1

0
$block = $this->getLayout()
->createBlock('mynamespace_mymodule/adminhtml_pdf_invoice')
->setData('invoice', "mydata")
->setTemplate('mynamespace_mymodule/pdf/invoice.phtml');  

Should be :

$block = $this->getLayout()
->createBlock('mymodule/adminhtml_pdf_invoice')
->setData('invoice', "mydata")
->setTemplate('mynamespace_mymodule/pdf/invoice.phtml');  
2
  • I got this: Fatal error: Call to a member function setData() . The fact that if i make a syntax error in my block I got the syntax message error. So it gets to my block. The problem is with my phtml file somehow, I guess. Oct 21, 2016 at 8:21
  • If i use you solution I got an error message as I said before. : ) Oct 21, 2016 at 9:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.