0

This question already has an answer here:

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.

Thanks

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.

EDIT

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.

marked as duplicate by Marius, Sander Mangel, Matthias Zeis, Amit Bera, Rajeev K Tomy Oct 27 '14 at 16:17

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 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 '14 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? – Renon Stewart Oct 27 '14 at 13:32
  • @R.S I have added code – Tom Burman Oct 27 '14 at 16:58
0

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 '14 at 16:51
  • added more details – Fabian Blechschmidt Oct 27 '14 at 18:19

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