boti
boti

Reputation: 677

Display Static Block in phtml

i want to show an static block directly in Template. I know that I can do this in this way:

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

That calls to the Static Block with the id 6. But this Block needs the Parameter product_id="product/1".

What I need:

<block type="test/test" product_id="product/1" block_id="8"/>

I want to set the Product Id in Template. It is possible to set the product id directly in the Template?

Such as

<block type="test/test" product_id="product/$currentProductId" block_id="8"/>

(For your Information. That Snippet should be placed at checkout/cart)

Thanks in Advance

Upvotes: 0

Views: 2362

Answers (1)

benmarks
benmarks

Reputation: 23205

Blocks have the so-called "magic getters and setters" via Varien_Object::__call(). You can therefore set your parameter by

$this->getLayout()->createBlock('cms/block')
                      ->setBlockId(6)
                      ->setProductId('product/1')
                      ->toHtml();

Upvotes: 2

Related Questions