Zend Framework - adding meta tags with property not working

facebook, facebook-graph-api, meta-tags, zend-framework

Solution

There is a hidden treasure in the view helper in the _isValid() method

// <meta property= ... /> is only supported with doctype RDFa

Unfortunately the error message you'll get is only to "please use setMeta()". The follow either in your controller or view should fix this problem.

$this->view->doctype('XHTML1_RDFA');  // controller
$this->doctype('XHTML1_RDFA');  // view

Problem

I am trying to use the facebook share button for which I want to dynamically set the title, description and image using the meta tags ``` <meta property="og:title" content="title" /> <meta property="og:description" content="description" /> <meta property="og:image" content="thumbnail_image" /> ``` This is the same question : Zend framework: Meta property integration I have tried doing what was suggested - but its not working This is what I've implemented in my layout.phtml ``` <?php $doctypeHelper = new Zend_View_Helper_Doctype(); $doctypeHelper->doctype('XHTML1_RDFA'); echo $this->doctype(); ?> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:og="http://opengraphprotocol.org/schema/"> <head> <?php echo $this->headMeta();?> </head> ``` Then in my views, I try setting the meta property as ``` <?php $this->headMeta()->setProperty('og:title', 'my article title');?> ``` But this code wont execute and i'm getting an error when the view is rendered - something along the lines of ``` Invalid value passed to set; please use setMeta() C:\webserver\apache\htdocs\dezyre\trunk\library\Zend\View\Helper\HeadMeta.php(164): Zend_View_Helper_HeadMeta->set(Object(stdClass)) ``` Any idea, whats wrong here Thanks for your help

Original source

Related problems