Im building a Social module aand one of the features is that the users can add their own Meta Cards like twitter:cards and opengraph data.

At the moment the user inputs their meta data into a simple text box like the cms page content box and the data outputs fine except dynamic values.

My question is how can i echo dynamic data in these meta tags in the head? e.g the current products name and description.

Obviously i don't want to save php in the db and it will just print the php anyway.I have also tried to define a block and template and a cms variable in the cms content but this again just outputs the block/variable declaration in the head instead of the value it should return.

Any ideas would be great.


EDIT Here is what currently outputs in the head:

<meta property="og:site_name" content="<?php echo Mage::app()->getStore()->getName();?>" />
<meta property="og:title" content="<?php echo $this->getTitle(); ?>" />
<meta property="og:description" content="<?php echo $this->getDescription(); ?>" />
<meta property="og:url" content="<?php echo Mage::helper('core/url')->getCurrentUrl(); ?>" />

Where the example PHP is i need to replace with data.


This is not a duplicated question. The users define the content in my use case therefore a static template will not work as defined in the links duplicated post.

  • I dont see this as a duplicate. I asking how to enter dynamic data in an admin textarea e.g. cms content so that it renders in the head so that users can input thier own meta tags. not simply adding a block and template
    – Tom Burman
    Oct 27, 2014 at 11:38
  • Can you add some code? What dynamic data do you want to display and what method are you using to display it? Oct 27, 2014 at 13:32
  • @R.S I have added code
    – Tom Burman
    Oct 27, 2014 at 16:58

1 Answer 1


Magento Templates support variables, so what you need to do is, pass all the stuff you want into the cms block, then you can use {{product.id}}, etc.

Checkout \Mage_Sales_Model_Order::sendNewOrderEmail so around app/code/core/Mage/Sales/Model/Order.php:1315 you see how this works for emails. Afaik works this the same way for cms blocks, but I'm not sure, just check it out.

You can see here $processor = $helper->getBlockTemplateProcessor(); how this works \Mage_Cms_Block_Block::_toHtml. Happy digging.

If you have more problems, post another question.

  • Could you expand on this please. For instance how would i get the current page title/description in my cms content?
    – Tom Burman
    Oct 27, 2014 at 16:51
  • added more details Oct 27, 2014 at 18:19

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