friday tips

Meta tags and custom title in views

Has ever need to insert a custom title in your drupal views? Or need to use meta tags in this so important for your project, views results?

A extremeley flexible solution can go throug creating your own custom views templateviews-view.tpl.php (or views-view--NAME-OF-VIEW.tpl.php). Then you can use the Drupal api to insert whatever you want, title, meta tags, ...

Example:

<code>drupal_set_title('bodas');

</code>

or even more flexible:

<code>if(arg(1)) drupal_set_title('bodas en '. arg(1));

else drupal_set_title('bodas');

</code>

And more "magic", meta tags in views:

<code>drupal_set_html_head('<meta name="keywords" content="bodas, '.arg(1).','.arg(2).'" />');

if(arg(1)) drupal_set_html_head('<meta name="description" content="listado de empresas de bodas" />');

else drupal_set_html_head('<meta name="description" content="listado de empresas de bodas en '.arg(1).'" />');

</code>

That was my friday tip :-).

More tips link: http://foreverheavy.com/10-quick-and-dirty-drupal-tips/