Programming in Magento Way

October 8, 2008 by hejian

Get URL

Root URL

<a href="<?php echo $this->getUrl('') ?>"><img src="<?php echo $this->getLogoSrc() ?>" alt="<?php echo $this->getLogoAlt() ?>" /></a>

Skin URL

$this->getSkinUrl('css/hejian-custom.css');

Display a CMS block in phtml

echo $this->getLayout()->createBlock('cms/block')->setBlockId('additional_info')->toHtml();

PDF generate
Module function:

public function getPdf() {
$pdf = new Zend_Pdf();
$style = new Zend_Pdf_Style();
$page = $pdf->newPage(Zend_Pdf_Page::SIZE_A4);
$pdf->pages[] = $page;
……
return $pdf;
}

Controller function:

function pdfAction() {
$pdf = Mage::getModel('xxx')->getPdf();
return $this->_prepareDownlaodResponse('xxx.pdf', $pdf->render(), 'application/pdf');
}

Leave a Reply

You must be logged in to post a comment.

Wordpress template made by HeJian