2

I am trying to change certain Drupal behavior. I have traced this behavior back to a function in RDF core module, and would like to change what it does. The function in question is rdf_preprocess_node().

Getting what I want would seem as simple as removing one or two blocks of code from this function. So that's exactly what I tried doing: I copied the function into my theme's template.php, made the changes, renamed the function from rdf_preprocess_node to THEMENAME_rdf_preprocess_node. This did not work, Devel Themer did not list my THEMENAME_rdf_preprocess_node among the preprocess functions used.

I do not understand why this didn't work. Only other option that I know is to try and dig through what the function affected and undo it, which sounds horrible.

What's a practical way to change what a function from another module does?

2
  • 1
    rdf_preprocess_node() is just an implementation of hook_preprocess_node - rdf_preprocess_node() itself is not a hook.
    – AKS
    Apr 27, 2013 at 14:55
  • @ayesh, to be clear, does that imply that rdf_preprocess_node() cannot be overriden from another module/theme, and I have to implement my own hook_preprocess_node and undo changes made by rdf_preprocess_node()? Apr 27, 2013 at 15:05

1 Answer 1

1

This is actually pretty easy.

All you have to do is implement your own template_preprocess_node(). Then inside, it update the $variables that the RDF module made. If you want to update the header additions that it did, then implement a hook_html_head_alter(), and update those elements.

If you do this from your theme, then these will run after the RDF module. If you do it from a module, then you need to set the weight to be higher than the RDF module.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.