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.
By qqboy on
if (isset($variables['#theme']) || isset($variables['#theme_wrappers'])) {
$element = $variables;
$variables = array();
if (isset($info['variables'])) {
foreach (array_keys($info['variables']) as $name) {
if (isset($element["#$name"])) {
$variables[$name] = $element["#$name"];
}
}
}
else {
$variables[$info['render element']] = $element;
}
}
What I wonder is why we add this line,why not just
$variables = $element;
Can some one help us make it clear. Thank you very much.
Comments
.
Hi, its simple $variables will be passed by reference in your theme function so it will be multidimensional array and it holds values which assigned on other functions.
so when you will do $variables = $element; it will override value of $variables with $element.
To realize this, you can print $variables in start of your function.
Hope this will make sense and clear your doubt.
Thanks,
Kuldip Gohil
Thank you good idea very
Thank you good idea very clear.
https://www.drupal.org/project/image_captcha_indicator
https://www.drupal.org/project/ext_js