By tramp-man on
Hi i have successfully overriden the "views_filters" all went well and it works great. however im trying to override the "forward_link()" function in the foward.module in the same way.
by putting an entry into template.php in the format function phptemplate_forward_link(), but i can get it to even call the function.
has any one got any ideas or help
thanks
Comments
template.php overrides
Hi!
I was under the impression that only functions called theme_function_name() can be overridden by phptemplate_function_name() or yourtheme_function_name()...
Pete.
template.php overrides
does that mean i cant override them then, or just not using the template.php file
andrew
Doesn't look like it
According to the documentation I've read :-(
Pete.
same issue
I ran into the same issue. You can definitely override a-non theme_* fcn in template.php. It catches it and all. However, when i try to drupal_render the $form that is passed to it, it doesn't do anything.
I am somewhat new to drupal. I sent an email regarding this question to the email list, but no one has responded with anything.
The documentation only seems to refer to overriding theme_* fcn in template.php. I could not find anything else.
It would be great if someone who actually knows the stuff would respond.
mat
You can not override any function you want
You can override all functions beginning with theme_*
There is no themeable function to theme link, forward_link uses hook_link and the output to the theme is globaly controled with theme_links.
See more informations here:
Customising how links ($links) are displayed in your pages
A way to add styling to individual parts of $links
Display only some of the links
Or you can always create your own link with l function... (/forward/node->id)
__________________________________ ____ ___ __ _ .. .. .
http://sotak.co.uk
drupal services -- webdesign
My personal blog | twitter:@sotak
Then why does it work?
Ok,
so i guess it is safe to say that one is not SUPPOSED to override a non-theme_* function in phptemplate? (is that correct)?
I followed the tutorial by Nick Lewis (see http://www.nicklewis.org/node/845) where he overrides the user_login function (there is not theme_user_login as far as i know) in template.php. So that means that you can override even functions that do not start with theme_. That was for drupal 4.7 (and it also works for me : drupal 5.1). So is that not a defined behavior (or at least discouraged) anymore ? But then, how come it still works?
Further, it works, except the drupal_render function does nothing in the defined callback fcn. It doesn't even throw an error.
Anyway, I am still a little confused. I have searched quite a bit and have not really come up with anything.
mat
It works because they are also theme functions
In this case the functions produce a form, but they are still theme functions which is why the override works.
The user_login function he
The user_login function he is overriding is called by drupal_get_form function.
Then what happens in drupal_get_form is, that drupal_render_form is called (http://api.drupal.org/api/function/drupal_render_form/5)
If you look closer into the code of drupal_render_form you will notice that there is a line with
theme_get_function($form_id)
again refer to drupal api and see what theme_get_function does: http://api.drupal.org/api/function/theme_get_function/5
it is checking if there is a function called:
yourthemename_formid, if not then it checks for phptempalte_formid -> if not then theme_formid
so you cant override all functions in drupal. You can override only themeable functions which begins with theme_* and you can override functions called by drupal_render_form (form rendering)
see also http://api.drupal.org/api/group/themeable/5
hope it helps
__________________________________ ____ ___ __ _ .. .. .
http://sotak.co.uk
drupal services -- webdesign
My personal blog | twitter:@sotak