I found many issues for "addind metatags for page display of views". But didn't found any for: displaying metatags as fields in Views.

I have administration view (table):
VBO-content | Nid | Title | Author | Published | Created | edit link

How to add there some Metatag as column?
I need display it and filter by it to easily find non-tagged nodes.

Or am i blind? Spent about 2 hours of trying.



Ok, now i found it as mostly impossible.
Hm, storing metatgs as serialized array is maybe good for performance, but a hell for working with that programatically and SQL...

I will let it open if someone has some proposal.

new1.12 KB

First workaround attached.
Only thing it does is showing full serialized data as string, filter as normal views string.
Works only with nodes at this time.

I expect i will create more views handlers in future with unserialize data and also more entity_types support (at least taxonomy_term).

Are you trying to do something like the following? I'm not exactly sure how we could support filtering on serialized data.

Yes i am trying something like this. At the moment great result for me is: have metatags / dont have metatags.

I used this PHP field:

if(strlen($row->data)) {
$arr = unserialize($row->data);
is_array($arr)) {
$arr as $delta => $tag) {
$delta == 'robots') {
'<strong>' . $delta . '</strong>:<br />';
foreach($tag['value'] as $d => $t) {
'- ' . $d . ': ' . $t . '<br />';
    } else {
'<strong>' . $delta . '</strong>: ' . $tag['value'] . '<br />';

Not ideal but better than nothing.

We are finishing website and 2 people working on metatags - i dont have any other idea how to help them with searching content without tags.

Title:Views supportExpose meta tag data as a Views field

Clarified the title.

I ran into this just now and thought I'd share an easy workaround using computed_field. We wanted to filter by (not display) metatag keywords in a Views search, so that people can type "schools" and see a result for "Education", and staff don't have to double-handle keywords.

  • On the content type, add a computed_field field named 'field_keywords' with text storage
  • On the content type, set display of the field to off (I only want it to produce results in search, don't do this if you want to display metatag values)
  • On the view, add display fields for the fields you want to filter against (title, body, keywords for me), setting Exclude from display
  • Also on the view, add a combine fields filter for the fields you want to filter by
  • Function to store the field is defined in custom module - see below

* Compute value for field_keywords, so we can use the result as a
* filter result in views.
* Metatag module stores as serialized data, which makes keyword
* filtering hard. Ref d.o #1906578.
function computed_field_field_keywords_compute(&$entity_field, $entity_type, $entity, $field, $instance, $langcode, $items) {
  if (isset(
$entity->metatags['keywords']['value'])) {
// split comma,separated,words to plain words (maybe redundant?)
$entity_field[0]['value'] = str_replace(',', ' ', $entity->metatags['keywords']['value']);
  else {
$entity_field[0]['value'] = NULL;

EDIT: Code updated to include else block, otherwise your computed result won't clear if you zap the stored metatags for a node.

Because I wanted this specific filter result, I didn't check until after doing this if Metatag implemented hook_node_search_result() to produce keyword match results. Looks like it doesn't (#1368298: Index metatags for core search at time of writing).

You could easily build on the above to obtain displayable Metatag results. Sure, you're duplicating data in the DB, but consider it a cached display or search query table and that shouldn't keep you awake.

I've only tested this for about five minutes, I'll let you know if it's a wreck :)

Note that if the keywords value in your Metatags fields is empty, nothing will be stored - I expect this solution will only display *custom* keywords per-node, not site-wide keywords.

For someone who will face same problem (show metatags as field, like title or nid)

1) Install & Enable Views PHP module
2) Go to your view and add Node Id as field
3) Add field Global -> PHP code
4) Add this as output code

For keywords:

$metkey = $result->metatags['und']['keywords']['value'];
print (

For description

$metkey = $result->metatags['und']['description']['value'];
print (

And that's it! Hope it will help you to spend 2-3 hours of your life better ;)

there should not be:



and yes, you are totally killing performance by using node_load() on all rows.

karlos007 ,

yes, you're right.
Better idea?

Title:Expose meta tag data as a Views fieldExpose meta tag data as a Views field [SOLVED]
new2.4 KB

Thanks a lot, I have developped a little module inspired by #2.

See attached file


@mgerbault: That's an excellent start, thank you! Would you mind if we take what you wrote and expand upon it with the goal of adding it to the main Metatag module?

@DamienMcKenna , yes if you want.
I need my module for a site where I use Metatag module ans sub-modules.

I suppose you can add meta keyword ...


I don't know that I would call this one solved. In my testing, the module from number 10 did not work for views displaying taxonomy terms. It seems to be specifically for nodes.

Title:Expose meta tag data as a Views field [SOLVED]Expose meta tag data as a Views field (sandbox)
Issue summary:View changes

@cameronbprince: The initial request was to provide integration for nodes - in that regard the solution in #10 will probably work.

But I think we can all agree that we should aim for a full integration. I started a new sandbox and claimed the name "metatag_views_field" since mgerbault didn't create a sandbox of his own.
The basic idea is outlined in the description. I've also created issues for each 1.0 step to help in planning. I haven't looked much under metatag's hood yet, so any input on the provided issues is appreciated.

Version 1.0 (and probably also 1.1) are requirements for a current project, so expect results in the next 2-3 weeks.