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 this page's documentation the following code example is given:
function hook_theme_suggestions_HOOK(array $variables) {
$suggestions = array();
$suggestions[] = 'node__' . $variables['elements']['#langcode'];
return $suggestions;
}
I think it would be clearer if we used:
function hook_theme_suggestions_HOOK(array $variables) {
$suggestions = array();
$suggestions[] = 'hookname__'. $variables['elements']['#langcode'];
return $suggestions;
}
In the original example the 'node' hook is used. For generality, 'hookname__' would be more appropriate.
Comments
Comment #2
dawehnerThis sounds like a good idea! Do you want to provide a patch?
Comment #3
WebKings.caI don't think we can patch a documentation page...
I tried looking for the "edit" tab on the API page documentation but it's not there. I think its because it's locked for a person with higher permission.
Comment #4
prajaankit CreditAttribution: prajaankit commentedComment #5
prajaankit CreditAttribution: prajaankit commentedHi ahmad.h.khalil,
Patch will be the good solution, people see the example in core files first,
so we change in core api, it would be more helpful for the user.
Comment #6
prajaankit CreditAttribution: prajaankit commentedComment #7
WebKings.caGood to know @prajaankit...
I think with this change the code would be clearer...
Comment #8
prajaankit CreditAttribution: prajaankit commentedComment #9
Dinesh18 CreditAttribution: Dinesh18 as a volunteer commentedIt is much more clearer using "hookname" instead of node.
Looks great. +1 to RTBC.
Comment #10
WebKings.caBy the way @prajaankit I don't think a patch is the best solution since the first place people will look at is the actual API documentation on Drupal.org website. Anybody starting out to learn about Drupal 8 will look there first NOT in the core API files.
Secondly, if you look at this issue queue the component is "Documentation" not a core files issue. This should be fixed on the drupal.org documentation page
Read this link:
https://www.drupal.org/node/24565
Under "What to report in a Documentation issue"
It says:
"A page that you don't have permission to edit (request that the page be unlocked so that you can edit it to fix the problem)."
Also:
Comment #11
WebKings.caDocumentation page on drupal.org still not changed. Required change has to be implemented.
Comment #12
WebKings.caComment #13
prajaankit CreditAttribution: prajaankit commentedHi @ahmad.h.khalil,
i Checked that how to change in api document, AS well as update in drupal core also, it would be helpful.
Thanks
Comment #14
prajaankit CreditAttribution: prajaankit at ]init[ AG commentedThanks
Comment #15
WebKings.caThis issue is regarding the api.drupal.org documentation page NOT the core Drupal files. So the purpose of this issue is to fix the actual api.drupal.org as seen in the link provided in the initial issue description. To change the actual core files make another issue.
@prajaankit Do NOT change the status of this issue until it's resolved. OR Fix it yourself in the API Page at the following link:
https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Render%21theme.api.php/function/hook_theme_suggestions_HOOK/8.2.x
Since the original issue in question is not resolved, I'm re-opening this issue.
Comment #16
cilefen CreditAttribution: cilefen commented@ahmad.h.khalil Thank you for your interest in this issue. There are some things you should know:
I hope this helps!
Comment #17
cilefen CreditAttribution: cilefen commented@prajaankit Thank you for providing a patch on this documentation bug. Please be aware that all reviews are peer-based so it is not permitted to mark one's own patches as "Reviewed and tested by the community". Overall, you've done a nice job—please continue helping on issues!
Comment #18
cilefen CreditAttribution: cilefen commentedOne more thing: I have retitled this issue for clarity.
Comment #19
WebKings.ca@cilefen I am updating the following link to indicate this vital piece of information. Thanks for the clarification.
https://www.drupal.org/node/24565
Comment #20
Dinesh18 CreditAttribution: Dinesh18 as a volunteer commentedChanging the status to RTBC.
Manually applied the patch as mentioned in #9
Comment #23
Gábor HojtsyI was wondering if hookname was the right thing or not, so did this:
So apparently there is prior art for using hookname_.
In fact that is in:
Which is the alter counterpart to this hook. So looks good to me.