By liaolliso on
Hey guys,
I met a problem when i want to use drupal_get_form in template.php
The situation is that i use zen and xxx stands for the theme name. And i give
$hooks['user_pass'] = array(
'template' => 'user-pass',
'arguments' => array('form' => NULL)
);
in xxx_theme() function.
And in function xxx_preprocess_user_pass(&$variables) {
print_r (drupal_get_form('user_pass'));
// here it give me the error that Maximum function nesting level of '200' reached, aborting!
}
Any one knows how to deal with this?
Any suggestion appreciated!
Comments
Remove the re-entrant statement
Hi,
Search engines are services you can use on the internet to find information. I like to use search engines to find information. Search engines are some of my favorites services on the internet. You can use most search engines for free :)
I used my favorite search engine on "Maximum function nesting level of '200' reached" to get lots of great answers to your first question.
I used Google. Google can be found at : http://www.google.com
Why not remove the re-entrant statement:
I would also consider using a debugger. A debugger allows you to diagnose coding issues. A debugger allows you to identify issues like re-entrant call execution. I like to use search engines and debuggers to diagnose issues.
Of course i searched, but the
Of course i searched, but the result was not what i want.
I want to use drupal_get_form() in that function. Why do you want me to remove this?
drupal_get_form() shouldn't
drupal_get_form() shouldn't be printed anywhere, it should be returned. It definitely shouldn't be being used in your .tpl.php files. Template files shouldn't be using any php other than simple if/else logic. Any processing should be done in your template.php file. You can create your form in that file using a preprocess function (preprocess_page() should work) then outputting the variable in your .tpl.php file.
Contact me to contract me for D7 -> D10/11 migrations.
Why should i create the form
Why should i create the form again?
Since i have created that form in the module, why can't i use it in template.php through drupal_get_form()?
Templates are for templating
Templates are for templating - i.e. theming output. Function calls are processing. The whole idea behind building a templating system is to separate the processing logic from the themed output. You are mixing them - and in this case I think it is what is causing your troubles. Though I could be wrong - I've never had your specific problem.
You should call drupal_get_form() in your preprocessing fuction, and assign it to a variable, then output that variable in your template. I think this will solve your troubles.
Contact me to contract me for D7 -> D10/11 migrations.
You could at least help a
You could at least help a user in it's issue if you have the answers, otherwise it's best to keep your inappropriate opinion for yourself.
Sincerely,
Gabriel Ungureanu
https://ag-prime.com/
I did help him - I told him
I did help him - I told him how it's supposed to be done. This would have solved his problem. And my 'opinion' wasn't inappropriate, nor was it an opinion, it was an explanation of how the templating system works in Drupal, and how it's effectively used.
Contact me to contract me for D7 -> D10/11 migrations.