Problem/Motivation
The entity system in Drupal 7 provides a mechanism to handle all data structures using unified hooks. While this concept was applied to the node system, it was not fully applied to the taxonomy system thus several expected hooks do not exist.
Proposed resolution
Trigger hook_entity_view and hook_taxonomy_term_view during the display execution for taxonomy term pages.
Remaining tasks
Selection of an appropriate implementation for Drupal 7 that reduces the chance of introducing compatibility problems.
User interface changes
None.
API changes
Both hook_entity_view and hook_taxonomy_term_view would trigger during the page load of a taxonomy term page.
Original report by Dave Reid
We are missing important calls to hook_entity_view() and there is no hook_taxonomy_term_view() unlike all other entities so it makes it hard for an entity-general module (like the Meta tags module) to be able to simply use hook_entity_view() for it's code rather than having to maintain 15 different view hooks.
Comments
Comment #1
Dave ReidThis affects the Metatags module for D7.
Comment #2
valthebaldAttached should solve the problem (added module_invoke_all('entity_view') to taxonomy_term_page)
Comment #3
Dave ReidWe need to actually store that return data and have it be output on the page... and we also need to call hook_entity_view() as well.
Comment #4
Dave ReidComment #5
Dave ReidComment #6
valthebaldWhere do you think it's necessary to store hook result? Module additions should be stored in $entity->content:
The module may add elements to $entity->content prior to rendering. The structure of $entity->content is a renderable array as expected by drupal_render().
(http://api.drupal.org/api/drupal/modules--system--system.api.php/functio...)
About output - it is possible to rely on current check if (!empty($term->description)) or replace it with other condition (but which one - no idea)
Comment #7
valthebaldComment #8
Dave ReidGah, that's true. I had a plan to make this more like node views, and add a taxonomy_term_build_content() function that handles all the hook and page output.
Comment #9
valthebaldI suggest simple change in logic - if modules have filled $term->content, call taxonomy_term_view (see patch)
Comment #10
Dave ReidNote that #796692: Only show the term heading if the term has a description will likely help us part of the way by allowing hook_entity_view_alter() and hook_taxonomy_term_view_alter() to be executed.
Comment #11
Damien Tournoud CreditAttribution: Damien Tournoud commentedTo the *term*, I guess? Also, are we consistent in invoking
hook_entity_view()
for all core entities?Comment #12
valthebaldOf course, *term*
Regarding consistency - isn't it a little bit outside the scope of this specific issue?
In any case, addition of hook_entity_view call makes taxonomy_term_page more consistent than now.
If you ask my opinion, better consistency can be achieved if hook_node_view and hook_user_view are discarded in favor of unified hook_entity_view, which would be called in every _view function.
Comment #13
valthebaldBy the way, how can I cancel original patch and replace it with the last one?
Comment #14
valthebaldComment #15
andypostsubscribe
Comment #16
valthebaldWhat's the process now? What steps are needed to move this issue to another status (rtbc=>patch to be ported)?
Comment #17
BTMash CreditAttribution: BTMash commentedI'm following up in here based on my issue (#1187810: Taxonomy module should also invoke hook_entity_view on taxonomy view - wish I'd done a better search ^_^), I was expecting what you have in taxonomy_term_page to be in
function taxonomy_term_view()
. I guess I'm imagining if in the event there are other display modes for the taxonomy (to be used in views / whatnot) that this behavior would allow for those build modes to also run the currently missing hooks. But maybe I'm missing something that makes it difficult to have this intaxonomy_term_view()
?Comment #18
mparker17Subscribe
Comment #19
valthebald#17: This issue is something different. taxonomy_term_page (page callback) does not call taxonomy_term_view(), if term description is empty. So it would not help if you invoke hook_entity_view in taxonomy_term_view.
Comment #20
BTMash CreditAttribution: BTMash commentedBased on the name of the issue, my assumption was this tackled any context of when the term is being viewed (in the different display modes that can be created for the term which means pulling up the viewing of a taxonomy term via a module like views on another viewing of a taxonomy page). In my scenario, the use case is that the term page is used to display upcoming events that have that term and I have an archive view page that displays the taxonomy term in another view mode (the different view mode displays all past events). Having hook_entity_view only in taxonomy_term_page does not allow for other modules to add in their content based on (the lack of) such modes.
Also,
taxonomy_term_page
is called on by taxonomy_term_page (atleast what I see via drupalcode.org - line 35 onwards of http://drupalcode.org/project/drupal.git/blob/refs/heads/8.x:/modules/ta...).Comment #21
valthebald8.x and 7.x behave not the same, see #796692: Only show the term heading if the term has a description
Comment #22
BTMash CreditAttribution: BTMash commentedLooking at what is in the head of the drupal 7.x and the 8.x branches, the if conditional from that issue in taxonomy_term_page is no longer there. And again, it discounts what happens on other view modes. They would not necessarily call taxonomy_term_page_view for hook_entity_view to run - they would be calling taxonomy_term_view. To me, it seems like taxonomy_term_view should be behaving in the same manner as the node and user modules.
Comment #23
BTMash CreditAttribution: BTMash commentedI'm not sure if I've been going off on a tangent but I decided to test it with a case that I know hasn't worked - with any module that implements
hook_field_extra_fields()
. I've decided to test out if the patch works by creating a module that implements it and used devel generate to generate the nodes and terms for this. And I implementedhook_entity_view()
to display some stub content. The content shows up fine on a node view, comment view but not for a taxonomy view (I couldn't test out the user view though from looking at its code and how it is set up similar to nodes and viewing them, it should work as well).The code I used to test this is at https://github.com/btmash/Taxonomy-Testing (would the proper protocol be to have the code in a sandbox on d.o?) since my simpletest writing skills are poor.
Comment #24
BTMash CreditAttribution: BTMash commentedOk, I'm giving this a shot with some other stuff added in. Namely turning the nodes that are shown into an extra field that can be set where to display within the set of fields on the page. It seems to work with the taxonomy testing module above and the items get reordered as necessary. It needs a thorough review, however.
Comment #26
BTMash CreditAttribution: BTMash commented#24: taxonomy_term_build_extension_1067120_d8_25.patch queued for re-testing.
Comment #27
BTMash CreditAttribution: BTMash commentedSome small cleanup of what was in there.
Comment #28
BTMash CreditAttribution: BTMash commentedIt seems like the test failed due to me trying to set
drupal_set_title()
. Removed that part along with some more unnecessary code.Comment #29
redndahead CreditAttribution: redndahead commentedHere are some nitpicks. Didn't really review the functionality.
Add comma after the closing ")"
Remove Extra Spacing
Remove extra spacing
Remove extra spacing
1 days to next Drupal core point release.
Comment #30
BTMash CreditAttribution: BTMash commentedUpdated patch with cleanup of spacing.
Comment #31
BTMash CreditAttribution: BTMash commentedAck...forgot to mark as needs review.
Comment #33
BTMash CreditAttribution: BTMash commentedPatch updated to create a build variable to pass on into drupal_render.
Comment #34
BTMash CreditAttribution: BTMash commentedGah...I forgot the one line with extra whitespace. Let's try again...
Comment #35
BTMash CreditAttribution: BTMash commented#34: taxonomy_term_build_extension_1067120_d8_34.patch queued for re-testing.
Comment #36
BTMash CreditAttribution: BTMash commented#34: taxonomy_term_build_extension_1067120_d8_34.patch queued for re-testing.
Comment #37
BTMash CreditAttribution: BTMash commentedGiven the patch has passed automated testing, would someone else be able to review the patch?
Comment #38
Dave ReidThinking about this... that maybe we need to abstract 'display nodes tagged with this term' out of these API functions as terms can be attached to anything and not just nodes. We won't be able to use these functions when displaying forum terms. If the functions just displayed the term description and called the hooks then it could be.
Comment #39
BTMash CreditAttribution: BTMash commentedHmm...I would love to modify the patch in #34 further so we have the things @Dave Reid mentions. However, I do not know what the scope of this patch is supposed to be and more importantly, I will need some guidance with getting it working as intended.. I modified valthebald's code so we have something else up and running. HOWEVER, I have expanded on TaxonomyHooksTestCase basic test that will test implementation of hook_taxonomy_term_view (and hook_entity_view) on a page view. Getting this further along would be beneficial as well but atleast we have something working on a core basis (and we can now see if the test fails on the page view to call the hooks).
Comment #40
BTMash CreditAttribution: BTMash commentedAck...whitespace errors.
Comment #41
BTMash CreditAttribution: BTMash commentedWoops, entity view needs to use $entity, not $term.
Comment #42
BTMash CreditAttribution: BTMash commentedIn talking with @Dave Reid on irc, he recommended I modifying the previous patch (but not include the display nodes portion as an extra field but as something added to a normal page). Setting to needs work so I remember to tackle it.
Comment #43
BTMash CreditAttribution: BTMash commented#34: taxonomy_term_build_extension_1067120_d8_34.patch queued for re-testing.
Comment #44
BTMash CreditAttribution: BTMash commentedOk, the new patch is based off the work done in #34 except that the node retrieval is now only limited to the term page view. The other build modes won't have it available as a field to add (in its current state, it is limited to nodes which would make sense on why not to do so; should likely be a separate issue). Tests added in and things seem to pass.
Comment #45
BTMash CreditAttribution: BTMash commentedAck...some whitespace issues along with a call on devel. So minor cleanup.
Comment #46
andypostphp-doc is the same
What this wrapper for?
7 days to next Drupal core point release.
Comment #47
BTMash CreditAttribution: BTMash commentedTalking about this on irc, the latter is to try and be on the same playing field as node_view is on (and go through the same steps). Comment seems to go in a similar route so going with the behavior of the majority of the core entities (could be useful in other ways down the line?).
Attaching patch with updated php-doc.
Comment #48
BTMash CreditAttribution: BTMash commentedAck...forgot to set to 'needs review'
Comment #49
christefano CreditAttribution: christefano commentedI didn't review the functionality but this conforms to coding standards.
Comment #50
jdolan CreditAttribution: jdolan commentedSubscribing.
Is this something we should expect in an upcoming D7 point release, or is it a ways out? I'm particularly interested in having hook_entity_view implemented for Taxonomy terms.
Comment #51
BTMash CreditAttribution: BTMash commented@jdolan, This will first need to land in D8 (and hopefully, the patch is in a state that it can be backported to D7). Further review would certainly help speed up the process towards getting it in core :)
Comment #52
kmajzlik CreditAttribution: kmajzlik commentedjust subscribing from #1111222: How to use it? (what a nice id :) )
Comment #53
Dave ReidComment #54
BTMash CreditAttribution: BTMash commented#47: 1067120_47.patch queued for re-testing since I am not sure if the patch needs to get rerolled.
Comment #56
BTMash CreditAttribution: BTMash commentedTry the rerolled patch.
Comment #57
BTMash CreditAttribution: BTMash commentedMark as needs review.
Comment #58
xjmVery minor point, but these should begin "Generates" and "Constructs."
Tagging as novice for the task of rerolling the Drupal 8.x patch on account of #22336: Move all core Drupal files under a /core folder to improve usability and upgrades. When you reroll, please incorporate the minor comment corrections above.
If you need help rerolling this patch, you can come to core office hours or ask in #drupal-gitsupport on IRC.
Comment #59
BTMash CreditAttribution: BTMash commentedAssigning the patch to myself since no one else has taken on it :) Will unassign once I reroll it and add your suggested changes.
Comment #60
BTMash CreditAttribution: BTMash commentedOk, patch has been rerolled for the core changeover and with comments from @xjm.
Comment #61
BTMash CreditAttribution: BTMash commentedForgot to unassign after adding patch.
Comment #62
BTMash CreditAttribution: BTMash commented#60: 1067120_60.patch queued for re-testing.
Comment #63
xjmAlright, I haven't done a complete review yet, but here are a few things I noticed so far:
Maybe we should add @see to the test cases these support, and/or a brief decription of their purpose? The reverse might also be a good idea (adding @see to these in the test method).
This is a good comment; however, it confused me at first because the line that follows is not obviously related to the comment. Can we move these lines (comment and definition of
$uri
both) down to just above the lines that are added later?This comment needs a period. Also, I'd change it to:
// View the term and ensure that hook_taxonomy_term_view() and hook_entity_view() are invoked.
The assertion text here isn't quite grammatically correct. Maybe all we need is:
Also, note that parens should be used after the hook name. Finally, we probably do not need to use t() for assertion messages. See #500866: [META] remove t() from assert message.
I'm also a bit hesitant about the function
taxonomy_term_show()
. Do we need this factored into its own function? Is that the best name for it? Should it have more documentation as to what its purpose is? Etc.Comment #64
BTMash CreditAttribution: BTMash commentedThanks for the review. I'll figure out how to make the changes you've recommended.
As for the function
taxonomy_term_show
, the reason I felt this needed to be factored into its own function was because I wanted it to be similar to how node works (node_page_view
->node_show
->node_view_multiple
->node_view
) and hence we have the same style of naming convention.Comment #65
BTMash CreditAttribution: BTMash commentedOk, I've attempted to make the changes you recommended. I wasn't entirely sure on how to write out the
@see
references (I figured it made more sense at the top of the file/class where it was being used. I've kepttaxonomy_term_show
as it is for now, however.Comment #66
BTMash CreditAttribution: BTMash commented#65: 1067120_65.patch queued for re-testing.
Comment #67
BTMash CreditAttribution: BTMash commented#65: 1067120_65.patch queued for re-testing.
Comment #68
sunStandardizing on "entity" tag, which will be renamed to "Entity system".
Comment #69
BTMash CreditAttribution: BTMash commented#65: 1067120_65.patch queued for re-testing.
Comment #71
BTMash CreditAttribution: BTMash commentedI'm removing the 'needs tests' tag since tests are included with the patch (hopefully it passes).
Comment #73
mrfelton CreditAttribution: mrfelton commentedNeeded this for D7. Here is a reroll against D7 that can be applied using drush make. It is the patch from #65 verbatim.
Comment #74
BTMash CreditAttribution: BTMash commentedFirst off, thank you @mrfelton. Someone else following up in the issue is very much appreciated :)
With that said, I haven't been following the status of the taxonomy module move to being in line with the work in the entity module (#1361232: Make the taxonomy entities classed objects)? Looks like its getting closer and closer. It seems like the patch for D8 is going to *wildly* differ from the patch for D7. In which case, is it even going to be possible for *a* patch to go in for D7?
Comment #75
Rontero CreditAttribution: Rontero commented#65: 1067120_65.patch queued for re-testing.
Comment #77
DamienMcKenna@BTMash: I think this patch would probably (I *hope*) fit within the somewhat expanded guidelines for accepting changes to the stable release discussed a while back.
Comment #78
joachim CreditAttribution: joachim commented> In which case, is it even going to be possible for *a* patch to go in for D7?
Indeed. This is either a bug in D7, or hook_entity_view() is lying.
This blocks flag module too BTW.
Comment #79
DamienMcKennaI tested the patch from #73 on a site with a related patch for Metatag (#1363476: Panels integration - ensure meta tags work OOTB on entity pages) and it works great.
Comment #80
DamienMcKennaFYI I've committed a patch to Metatag so that it now uses hook_entity_view() instead of unstable alternatives (thank you jenlampton!), so now I'm really interested in getting this committed :) If nobody else beats me to it, I'm aiming to work on any necessary polish for this patch so that maybe we can push it to be added to the next release.
If anyone has suggestions for alternative hooks to use (especially for backwards compatibility with older D7 releases), please let me know in #1700160: Support taxonomy term pages until taxonomy supports hook_entity_view(). Thanks.
Comment #81
dropbydrop CreditAttribution: dropbydrop commentedI hope this to get fixed soon for metatag D7.
thanks!
keep up the good work
Comment #82
DamienMcKennaA rerolled version of #65 that should apply cleanly.
Comment #84
DamienMcKennaDoh. This should work.
Comment #86
DamienMcKennaMaybe I should have reviewed the code I changed before submitting the patch :-p
Comment #87
DamienMcKennaComment #89
DamienMcKennaThis test is failing:
That suggests the hook is not working correctly. Urk.
Comment #90
DamienMcKennaWrong status.
Comment #91
corvus_ch CreditAttribution: corvus_ch commentedComment #92
corvus_ch CreditAttribution: corvus_ch commentedThe hook entity_view was called with the wrong parameters. I fixed this now and also made the patch to apply to current 8.x branch.
Comment #93
BerdirHere's a quick review...
Update for the PSR-0-ified test class name.
The first line of a docblock should not be more than a single line (nor longer than 80 characters...).
Usually this function is called view, which in this case already exists... Not sure what to do here.
This isn't up to date anymore, should use language() and the DIC.
Should use $term->uri().
Comment #94
corvus_ch CreditAttribution: corvus_ch commentedHere a new patch including Berdirs feedback.
As of the function naming, this is more or less consistent with other modules. A possible standardisation is going on in issue #1026616: Implement an entity render controller.
Comment #95
BerdirThat / should be \
Should be "@param Drupal\taxonomy\Term $term".
@return array
We unfortunately don't have a notion for an array of classes, so it's just @param array $terms here. The other @params and @return also need the type.
Same.
Comment is wrong ($node should be $term)
Comment #96
fgmRerolled accordingly. Having a unified view process will simplify #1026616: Implement an entity render controller: taxonomy terms are the only ones differing in their view process from the way comment / node / user do it.
Comment #97
corvus_ch CreditAttribution: corvus_ch commentedThere was one type hint missing.
Comment #99
fgmPatch at #96 does not have the same problem as the one on #97, which seems to be based on an earlier version. Main issue in #97 is taxonomy_term_view_multiple still having a Term $terms hint, whereas its first parameter is an array, not a Term.
Comment #100
corvus_ch CreditAttribution: corvus_ch commentedOops, sorry my bad. I have used the wrong type hint. Fixed with this patch.
Comment #101
fgmIndeed my #96 was missing a Term hint and an array hint. Good now.
Comment #102
BerdirWhile correct, this change is unrelated and should IMHO not be in this patch to avoid discussions/conflicts. If you can re-roll without that, then I'm happy to RTBC it. After all, we're going to delete most of this code again anyway in the entity render issue, this is really just a preparation to make the conversion there easier.
Comment #103
DamienMcKenna@Berdir: if this entire system is going to be scrapped in D8, can we give up on this change for D8 and instead focus it on D7?
Comment #104
Berdir@DamienMcKenna: The system will stay (the view API functions added here), the other issue will just replace the actual implementation of it with a generic one. So I think it makes sense to get this in and it's close now.
Comment #105
DamienMcKennaDoes this work? Also I fixed the spelling of "URI" in the function's comment.
Comment #107
Berdir#105: drupal-n1067120-105.patch queued for re-testing.
Comment #108
BerdirThe reason for removing the Term type hint there was to avoid including unrelated changes in this patch. The URI fix is exactly the same kind of unrelated change and just as problematic. Can we get a new patch with that removed and a separate issue opened to fix that function?
Comment #109
DamienMcKennaWithout the 'uri' change.
FYI I opened another issue to fix all misspellings of the acronym "URI": #1742958: All spellings of URI should be uppercase
Comment #110
BerdirYay, let's get this in then! (Edit: assuming this will pass the tests but there's no reason it wouldn't, it's just a comment change or better a not-change)
Comment #111
Berdir#109: drupal-n1067120-109.patch queued for re-testing.
Comment #113
fgmPatch no longer applies because parts of it were committed in the meantime.
Comment #114
corvus_ch CreditAttribution: corvus_ch commentedMade patch apply again.
Comment #115
BerdirLooks good, I confirmed manually that it works and the view mode alter stuff also works correctly (which was the reason the old patch conflicted).
Comment #116
fgmTagging for the Munich sprint.
Comment #117
DamienMcKennaI'd really, really, really like to see this added to D8 so I can reroll it for D7 and hopefully get it into the next stable release. Who do I need to send donuts / chocolate to so this can be committed? :-)
Comment #118
warmth CreditAttribution: warmth commentedI'm trying to get a link beside each content tag (using terms + Flags module) to report if the tag is not valid for that content (it doesn't represent anything real about the content) but I can get the link to appear and I think is because of this bug, can you please help me?
Sorry for cross posting here: http://drupal.org/node/1035410#comment-6399632
Comment #119
DamienMcKenna@warmth: Thanks for your interest, at a guess your issue should start to work once this item is resolved; that said, please deal with any follow-on either in the other Flag issue or open a new one for that module.
Comment #120
fgmNote: during the Entity API Munich sprint, issue #1026616: Implement an entity render controller was implemented as depending on this patch. I would thus really like to see it committed so that the other issue can be considered.
OR ... maybe we should roll it into the other one ?
Comment #121
DamienMcKennaDoes this need an improved issue summary, or just more hours in the day (and my patience)?
Comment #122
corvus_ch CreditAttribution: corvus_ch commentedAll this patch currently needs is to get the attention of a core committer. Currently there are still 43 Patches in the queue for committing. If it does not get committed soon this probably will need some rerolls for it will not apply any more. So this will take some more of your patience.
Comment #123
blischalk CreditAttribution: blischalk commentedI am also very interested in the status of this issue. I am trying to use hook_field_extra_fields to create "pseudo" fields as described in this article: http://www.computerminds.co.uk/drupal-code/add-stuff-node-and-configure-.... The method the author describes works just fine for nodes because hook_node_view exists. Because hook_taxonomy_term_view does not exist I am unable to apply this technique to taxonomies.
Comment #124
Summit CreditAttribution: Summit commentedHi, yes please, please commit #114 http://drupal.org/node/1067120#comment-6381112 and backport to D7 please!
Thanks a lot in advance,
greetings, Martijn
Comment #125
Berdir#114: 1067120-114.patch queued for re-testing.
Comment #126
webchickNote: Begging for features doesn't get them committed any faster; fixing major/critical bugs and tasks so we get under issue queue thresholds does. :) That finally happened again tonight, so features are once again back on the table.
I read through this patch pretty extensively, checking it out alongside http://api.drupal.org/api/drupal/core!modules!node!node.module/function/... and http://api.drupal.org/api/drupal/core!modules!node!node.module/function/... and the like. Everything in this patch seems to make sense, and is simply unifying the taxonomy page functions w/ the node page functions.
Committed and pushed to 8.x. Thanks! Marking to 7.x for backport, although it's a pretty extensive change so could likely use David's sign-off. Temporarily assigning to him. An up-to-date issue summary, including the API impacts of this on D7, would help expedite his review. Tagging accordingly.
Comment #127
DamienMcKenna@webchick: Thanks!!! And your comment about bugfixing is noted.
I'll work on a re-roll and updating the issue summary.
Comment #128
BerdirI think the backport version of this should be as small as possible and not include any API changes. I'm quite sure we have to live with the inconsistent functions, missing multiple and so on and just add the hooks. More or less going back to the initial small patch, I guess.
Comment #129
David_Rothstein CreditAttribution: David_Rothstein commentedI looked this over and Berdir's comment makes sense to me. If the earlier patches in this issue are sufficient to solve the problem, those seem very straightforward (just adding new hooks) and get a +1 from my point of view.
In general, I don't see a problem with reorganizing code into new functions in Drupal 7 if we really have to... but the full patch here is pretty complicated and it seems like it has lots of opportunity to introduce (either intentionally or accidentally?) data structure or order-of-operations changes that could cause problems in Drupal 7. So at the very least, the simpler patches here would be a lot quicker to get reviewed and committed :)
Comment #130
DamienMcKennaI've updated the issue summary accordingly.
Comment #131
DamienMcKenna@David_Rothstein: The initial patches from valthebald do not add hook_taxonomy_term_view, while the patches from BTMash go on a tangent to change the actual output. I'd personally vote for just backporting the most recent patch as a) the execution is not that different, b) there weren't any hooks explicitly executed during taxonomy_term_page() so there's little-to-no chance of introducing any regressions. I'll have an initial patch in a few minutes.
Comment #132
DamienMcKennaThis is a reroll of mrfelton's patch from #73 which has been working well for me on a site I've been building over the past two months; other than some differences in between D7 and D8, including a different testing structure, it is pretty much identical to the patch from #114.
Comment #133
xjmChatted with @DamienMcKenna about this in IRC. The old patch needs a few changes to bring it back into line with the newer 8.x patch. Thanks folks!
Comment #134
DamienMcKennaSummary of differences between the D7 and D8 versions of taxonomy.module:
This is to support the new hook_entity_view_mode/hook_entity_view_mode_alter already added to D8 and in progress for D7 (#1154382: View mode no longer can be changed).
Summary of differences between the D7 and D8 versions of taxonomy.pages.inc:
This new patch changes the following:
I think this should cover everything.
Comment #135
DamienMcKennaMissed a period at the end of a comment.
Comment #136
brunorios1 CreditAttribution: brunorios1 commentedi tested and it worked in D7.
Comment #137
webchickWe're once again over thresholds atm so I unfortunately can't commit any feature patches. Help with smashing critical and major bugs would be greatly appreciated.
Comment #138
joachim CreditAttribution: joachim commentedAs I said above, I really think this is a bug. hook_entity_view() promises something that isn't delivered.
Comment #139
DamienMcKennaIt is a bug report:
I'm not sure why Dave did not file this as a bug report when he did file the sibling issue (#1122808) as a bug report.
Comment #140
DamienMcKennaThe various core issue queues are all at or under their respective threshold levels, is there anything else I can do to help ready this issue or should I just be a little more patient? :)
Comment #141
DamienMcKennaFYI this patch still applies with #1154382: View mode no longer can be changed committed.
Comment #142
webchickProbably the best thing is not to repeatedly "bump" the patch, since I often process the D7 queue FIFO. :)
This still smells pretty feature-y to me, and we're once again over thresholds, but I can appreciate that this blocks contributed module progress, and Damien did a really nice job smacking around the thresholds the other week before I lost track of this patch. Therefore, I'm comfortable to go ahead and commit this. Thanks a ton!
Unfortunately, the patch no longer applies. :( Can we get a quick re-roll? And while you're at it, can you add a hunk to taxonomy.api.php to document this new hook addition? (NO idea how I missed that in the 8.x patch. :P) That should technically go against 8.x first, but I can do it manually from the 7.x patch.
Comment #143
DamienMcKenna@webchick: Thank you :-)
Does this work? I snagged the hook_node_view() code from node.api.php, changed it to say $term instead of $node and removed the part about the RSS feeds as it didn't seem accurate for terms.
Comment #144
BerdirAlmost :(
Comment #145
DamienMcKenna@berdir: Good catch. I didn't see another @ingroup in the taxonomy.api.php file so I just removed that line entirely.
Comment #146
BerdirYes, looks good.
Comment #147
webchickAwesome, thanks a ton!
Committed and pushed to 7.x, with api.php hunk to 8.x as well. YAY! :D
Let's get a change notice added for this.
Comment #148
BerdirThe 8.x should be updated a bit to follow the 8.x standards and be consistent with others, e.g. a type hint.
Comment #149
DamienMcKennaWhat should the change notice document - the new hooks in both branches or just 7.x? How about the following?
Comment #150
andypost#149 looks like good summary, D7 and D8 changes are the same so 1 change notice is enough. It would be good to provide an example code like #145 does in tests
Comment #151
DamienMcKenna@andypost: Like this?
Comment #152
andypost@DamienMcKenna Yes, Great! Please file a change notice and make critical--
Comment #153
DamienMcKennaPosted: http://drupal.org/node/1808870
Comment #154
andypostAs for me it describes all the changes
Comment #155
andypostBack to its original priority
Comment #156
David_Rothstein CreditAttribution: David_Rothstein commentedDrupal 7.16 was a security release only, so this issue is now scheduled for Drupal 7.17 instead.
Fixing tags accordingly.
Comment #157
warmth CreditAttribution: warmth commentedoh :(
Comment #159
David_Rothstein CreditAttribution: David_Rothstein commentedHm, I am playing around with this and seeing that while this patch mostly works as advertised (and works well), it also seems to result in some major data structure changes and HTML markup changes on the taxonomy term page.
The attached screenshots of Drupal 7.16 and (what is slated to become) Drupal 7.17 illustrate that, since I've included the output of dsm($build) for that page.
The data structure change probably only affects someone altering this via hook_page_alter() (probably not too common), but the corresponding HTML markup change is a big problem since this is a public-facing page (you can see it in the render array in the screenshot; the #prefix and #suffix that used to be there before are gone).
I am not sure we should release Drupal 7.17 tomorrow without some kind of resolution to this. I don't have a whole lot of time, but I'm trying to work on a quick patch for now.
Comment #160
David_Rothstein CreditAttribution: David_Rothstein commentedThe attached patch seems to work for me.
Basically, since we're only rendering one term anyway, we shouldn't actually need to go through the whole taxonomy_term_show() => taxonomy_term_view_multiple() pipeline on the term page. If we call taxonomy_term_view() directly, all the same hooks that were added in the original patch here should still get fired, etc. But now we get a data structure back that we can easily make compatible with previous releases of Drupal 7.
I also fixed a few references to "node" and node-related concepts that looked like they were the result of copy-paste from the node module...
This patch could REALLY use a review if anyone has time between now and tomorrow.
Comment #161
BerdirI haven't actually tested this, but i was working on a comment that proposed basically exactly what you just uploaded as a patch minus the documentation improvements.
Have you reverted the comment intentionally? It incorrectly talks about a node title I think but might otherwise be useful information? Other than that, the patch looks great to me and I agree that we should stick to the existing structure. if possible. The keys within the term looks identical to me, just a different order. Would have been a bigger issue if these were different too.
Comment #162
BerdirRemoving the change notice tag, that was added and is not affected by the proposed follow-up patch.
Comment #163
David_Rothstein CreditAttribution: David_Rothstein commentedThanks for the quick review.
Well, the whole paragraph seemed to be talking about setting the page title, but the code around it isn't actually setting the page title at all. So I assumed it was a bad copy-paste. Maybe the relevant parts of the code comment should be moved somewhere else?
Comment #165
BerdirLooks like we also need to update these checks as they obviously still use the other structure.
Comment #166
David_Rothstein CreditAttribution: David_Rothstein commentedYup. Here's a new patch which does that. I also moved/edited the code comment about the page title rather than deleting it.
Comment #167
BerdirI think this change makes sense and the actual patch looks good to me.
Comment #168
David_Rothstein CreditAttribution: David_Rothstein commentedThanks so much for the review.
Committed this to 7.x so we can get Drupal 7.17 out soon: http://drupalcode.org/project/drupal.git/commit/7208952
Comment #169
David_Rothstein CreditAttribution: David_Rothstein commentedActually, I guess I messed up a little bit by including the documentation fixes in there also, since some of those belong in Drupal 8 as well.
Can try to get that done eventually.
Comment #170
DamienMcKennaDavid, thanks for the follow-up work on this, Metatag users are all very grateful :-)
Comment #171
warmth CreditAttribution: warmth commentedThanks! Now that have been fixed is there any possibility of displaying them beside the tags on a content detail page (node tags)? I can only see the flag inside the tag page (the one that display all the items tagged with that taxonomy)!
Note: I couldn't find any thread talking about that, sorry if is not the proper place to do it.
Comment #172
thedosmann CreditAttribution: thedosmann commentedDid this get into 7.17?
Comment #173
DamienMcKenna@thedosmann: Yes.
Comment #174
thedosmann CreditAttribution: thedosmann commentedWow I just upgraded and lost all my meta descriptions in my forums I had from the patch I applied above.
Comment #175
DamienMcKenna@thedosmann: Open an issue in the Metatag issue queue and I can help you there.
Comment #176
thedosmann CreditAttribution: thedosmann commentedk
Comment #177
BerdirOk, I think that's all that's left to port back to 8.x from David's patch in #166, the other things have been removed as the render controller was added.
Quick RTBC so that we can finally close this issue?
Comment #178
DamienMcKennaI think this is good to go.
Comment #179
webchickYay for closing issues. :)
Committed and pushed to 8.x. Whew!
Comment #180
thedosmann CreditAttribution: thedosmann commentedI needed to footnote this. When I applied the patch above I did it from command line using the native nix patch command. I usually note when I do it this way but somehow overlooked. So when I went to 7.17 the files I patched didn't get updated. I had to go in as admin and delete the ones I patched and then plant the updated ones in meta tags. I didn't want to leave this dangling. After the update my meta tags came back. Thanks for the fix.
Comment #181
David_Rothstein CreditAttribution: David_Rothstein commentedComment #183
sic CreditAttribution: sic commentedMay someone be that nice and summ up what I need to do to make the view and view_alter hook work for my drupal 7.19? Thanks so much
Comment #183.0
sic CreditAttribution: sic commentedIssue summary updated.
Comment #184
rudolfbyker@sic, see my answer over on Drupal Answers.
Comment #185
andypostComment #186
David_Rothstein CreditAttribution: David_Rothstein as a volunteer commentedThis was committed to both Drupal 7 and 8 a long time ago.
To the best of my knowledge these hooks are consistently invoked when a term is being viewed - for example by taxonomy_term_page() which calls taxonomy_term_view() which invokes the hooks. The Drupal Answers post above is several years old and looks like it's out of date. However, if there is a problem with these hooks not being invoked, please create a new issue with details and link to it here.