eZ publish meta tag class and template

Meta tags may be valuable for SEO. A very nice implementation is to create a class with includes object relation lists to point to nodes that you would like to assign specific tags to.

The way it works is to find the reverse related objects (those objects that point to this node), and then extract out the tags. Depending on the complexity of your content architecture, this may require some tuning, but the basic concept is simple and has been used very successfully.


{* Add these lines to page_head.tpl to use this class *}

    {def $meta_tags=fetch( 'content', 'reverse_related_objects',
           hash( 'object_id',$node.contentobject_id,'all_relations',FALSE))}
 
      {if count($meta_tags)|ne(0)}

      <meta name="keywords" content="{$meta_tags.0.data_map.keywords.content|wash}" />
      <meta name="description" content="{$meta_tags.0.data_map.description.content|wash}" />
      <meta name="robots" content="{$meta_tags.0.data_map.robots.content|wash}" />

      {else}
  
        {section name=meta loop=$site.meta}
        <meta name="{$meta:key|wash}" content="{$meta:item|wash}" />

        {/section}
      {/if}

    {undef}

The package file isn’t posted due to security issues. It is reasonably easy to determine the class attributes from the template code.