Help with CHtml::metaTags

Hello,

I'm trying to insert dynamic meta tags using CHtml::metaTags method, but it is inserted above the <head> tag rather than within the tag.  As well, the html is outputted in reverse to conventional formats. 



<meta content="this is a test" name="description"/>


vs


<meta name="description" content="this is a test" />

I’m just using a statement like

echo CHtml::metaTag(‘this is a test’,‘description’)
at the beginning of an action. 

Here is the output I get…

<meta content=“this is a test” name=“description”/><!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/2000/REC-xhtml1-200000126/DTD/xhtml1-transitional.dtd”>

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

  <head>

      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

      <meta name="language" content="en" />

Am I using this incorrectly?  Should it not automatically stuff the meta tag within the head tag and the proper format?

Thanks,

R

I think you should use this function inside the View not inside the controller.

Try to put in layout.

\protected\views\layouts\main.php

Between <head> and </head> tags use this:

echo CHtml::metaTag('this is a test','description')

Thanks for your reply, but I don't see how this could be updated dynamically if it is inserted in a layout file.  What if I want the content to be different for each view that is tied to one layout? 

R

I do this way:

inside the controller in a action method:

class AppController extends CController


{


	public $metaDescricao = null;


}

And in the layout file:

<meta name="description" content="<?php echo $this->metaDescricao ?>" />

Get it?

Yes thank you, I understand this method.  It was outlined in this thread http://www.yiiframew…html#msg10327.