Code snippets for symfony 1.x


Refine Tags

Snippets tagged "metadata"

How to remove meta tags

You may find yourself wanting to remove default meta tags for specific modules within your application. This isn't possible through view.yml or module.yml, as we can only add or replace meta tags. We could add a removeMeta() method and call it from the module's pre- or postExecute() method, but as the default metas are added after action execution, that wouldn't work either.

The solution is to extend the sfWebResponse class, overriding the getMetas() method. This allows us to filter out unwanted tags without affecting special behaviour, e.g. for the title tag.

class myWebResponse extends sfWebResponse
  public function getMetas()
    $meta_tags = $this->parameter_holder->getAll('helper/asset/auto/meta');
    if ($this->getContext()->getModuleName() == 'special_module' && array_key_exists('bad_meta', $meta_tags)) {
    return $meta_tags;
by James McGlinn on 2006-06-17, tagged metadata  response 
(1 comment)

Get page title inside of template

$title = sfContext::getInstance()->getResponse()->getTitle();
by Dustin Whittle on 2006-05-22, tagged metadata