Hello,

I've enabled Metatag: Views

When I add a by path configuration, if the page matching the path is managed by a view the title is not overriden but description and keywords are.

I disabled the module Metatag: Views and the title is now as configured in Metatag.

But if I need to configure meta by path and by view it seems not possible.

Any ideas ?

Thanks

Comments

normunds lauva’s picture

I managed to solve this using setting "META TAGS" in view edit page and changing meta fields there.

damienmckenna’s picture

Version: 7.x-1.4 » 7.x-1.x-dev
marcelovani’s picture

Are we suggesting that the Metatag Context (By path) should have higher priority? In other words, if we create a context by path to set metatags, that should override Metatag views?

marcelovani’s picture

Status: Active » Needs review

I have changed the hook from page_build() to page_alter() which is the same hook used by Metatag Views

Then I make sure that Metatag Context always runs last

function metatag_module_implements_alter(&$implementations, $hook) {
  if ($hook == 'page_alter') {
    // Run metatag_context_page_alter() last.
    $group = $implementations['metatag_context'];
    unset($implementations['metatag_context']);
    $implementations['metatag_context'] = $group;
  }
}

Also, I am not sure why we were using 'global' as instance. I think it makes sense changing it to 'by_path'.

    $page[$region]['metatags']['by_path'] = $metatags;

Here is how I tested this:

  1. Create a view that has a page
  2. Create a Metatag Views configuration
  3. Visit that view and check if the metatags for the views come from the settings above
  4. Create a Metatag context by path (same as used on view)
  5. Visit the view again and check that the metatags come from the settings above
marcelovani’s picture

StatusFileSize
new1.25 KB

Patch here to be reviewed

marcelovani’s picture

StatusFileSize
new6.56 KB
new6.21 KB

Few more fixes and tests updated

damienmckenna’s picture

Status: Needs review » Needs work
Issue tags: -views, -by path, -title

This needs to be rerolled.

marcelovani’s picture

StatusFileSize
new2.83 KB

Re-rolled the patch #6.
I didn't have time to do the tests, please review the patch and if everyone is happy we can port the tests from #6

marcelovani’s picture

Status: Needs work » Needs review

If you are wondering why I removed hook_preprocess_html(), it's because I don't see any reason for it to be there.
I assume it was an attempt to override the page title, please correct me if I am wrong.
I tested the code without this hook and I was able to override page title with no problems.

damienmckenna’s picture

Status: Needs review » Fixed

Committed. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.