Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
In ctools.api.php the function hook_ctools_content_subtype_alter should take the variables $subtype and $plugin by reference. I guess this is just a miss in the documentation.
function hook_ctools_content_subtype_alter($subtype, $plugin) {
}
Should be
function hook_ctools_content_subtype_alter(&$subtype, &$plugin) {
}
So that the category name for example can be changed.
Comment | File | Size | Author |
---|---|---|---|
#1 | pass_variables_by_reference-2312267-1.patch | 510 bytes | pontus_nilsson |
Comments
Comment #1
pontus_nilssonAttached patch passes the variables by reference.
Comment #2
David_Rothstein CreditAttribution: David_Rothstein commented$subtype definitely should be, but why $plugin? The code which invokes this hook, ctools_content_prepare_subtype(), only takes $subtype by reference itself, so if you modify $plugin in this hook I don't think it would actually have any effect? (and I assume that's intentional)
Note that I included the change to take $subtype by reference as part of #2373297: hook_ctools_content_subtype_alter() does not provide any reliable way to identify the subtype being altered since I noticed that issue too and was already changing that exact line of code in the documentation.
Comment #3
pontus_nilssonGood catch. I think we can close this ticket in favor of #2373297: hook_ctools_content_subtype_alter() does not provide any reliable way to identify the subtype being altered
Comment #5
rivimey