Closed (fixed)
Project:
Metatag
Version:
7.x-1.x-dev
Component:
Code
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
20 Jun 2015 at 02:06 UTC
Updated:
12 Feb 2016 at 06:44 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
osopolarSorry, I am not familiar with metatag api to fix this in an proper way. Before the links are removed in
metatag_html_head_alter()they may be added to the global metatag default values (if they are empty), so they can be overridden later.To get prev and next to work now I added a workaround to my custom module to rename the elements, before metatag will remove them:
Comment #2
th3m0d commentedDisregard this comment. Wrong page by accident. Sorry.
Comment #3
damienmckennaThis isn't strictly a Novice issue..
The problem is that Metatag only checks if there could be a value, not whether there actually is a value.
Comment #4
damienmckennaPer #2502453: How to best use rel=next/prev in Views pages?, this also affects Clear Pagination.
Comment #5
Dieter Geiling commentedIs there any progress with this issue?
Comment #6
nikolay shapovalov commentedI found https://www.drupal.org/node/2415983.
We got this in comments.
So i think metatag should take care only about core tags, and the user shoud handle other tags from modules and themes by himself.
Or maybe we can add ['#access'] to render array instead unset element, and then implement
theme_html_tag()to handle new key.Comment #7
nikolay shapovalov commentedDisable access to tags instead of unset it.
Typo in this patch
use #10
Comment #8
hver commentedI have the same problem, my own "prev" and "next" tags are deleted by Metatag module.
To solve this, I use
drupal_add_html_head()instead ofdrupal_add_html_head_link()Comment #9
sebumd commented+1 to hver's solution above. My metatags are being deleted by the Metatag module.
I used the following module on github out of the box: https://github.com/nlisgo/nextprev_links but changed the drupal_add_html_head_link to the following drupal_add_html_head so that metatag doesn't intercept the metatags.
drupal_add_html_head(array(
'#tag' => 'link',
'#attributes' => array(
'href' => $head_link['href'],
'rel' => 'next',
),
), 'pager_next_link');
Comment #10
nikolay shapovalov commentedWith current patch metatag module will not delete any tags anymore.
It only disable access to it.
You can now chose tags to render
Comment #11
damienmckennaDoes this work? I've rewritten it to loop over the meta tags actually being output on the page, and only remove meta tags that specifically match against tags it recognizes.
Comment #13
damienmckennaAh, should probably verify that the variables are strings before running them through strtolower() X-)
Comment #14
damienmckennaThis needs tests to confirm the types of meta tags that are removed.
Comment #15
giupenni commentedNot Work, canonical and shortlink tags are not removed if value is empty
Comment #16
damienmckenna@giupenni: That might be because Drupal core adds those tags too?
Comment #17
giupenni commentedYes, I think this is possible.
How might to solve it?
Comment #18
damienmckennaI think we need a checkbox to control whether those core meta tags are removed anyway.
Comment #19
giupenni commentedI agree
Comment #20
siramsay commentedI just tested this as metatag module was removing rel prev/next added by flippy and it works nicely.
However now I get generator tag that was before removed by metatag module by not having a value, checkbox control for core meta tags will fix this so sounds like a good solution.
Comment #21
siramsay commentedI added back - // Remove the default generator meta tag.
- unset($elements['system_meta_generator']);
this works for my problem.
I was thinking that maybe core meta tags could be removed by metatag module as was the case before this patch and maybe the patch should just be aimed at not removing meta tags added by other contributed modules.
If this was documented then seem like leaving the field blank in metatag module is a good solution.
Unsure which would be easier since I have only looked at the code around the lines added and removed , so just a suggestion.
Comment #22
damienmckennaJust rerolling the patch, I haven't added tests or the new option yet.
Comment #23
damienmckennaLets finish this off for the next release.
Comment #24
damienmckennaPlease give this a test - it now removes core's meta tags by default, and adds a new option allowing them to be left in place. And it adds a test to confirm the functionality works as intended.
Comment #25
damienmckenna@size and @giupenni: Please give that patch a try, let me know if it solves the problem for you.
Comment #26
giupenni commentedGreat job DamienMcKenna. Seems to work like a charm!
Comment #28
damienmckenna@giupenni: Thanks for the review.
Committed.
Comment #30
siramsay commentedjust installed 7.x-1.11+1-dev (2016-Jan-27) and works as advertised, thanks Damien