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 tce on
I'm using hook_custom_theme() to determine a theme for a specific page, which is different from other pages. It works great but I've just found that when using an AJAX driven form on that page it styles the the returned form content in the default theme.
I realise that hook_custom_theme() is fired during the AJAX callback but for the page 'system/ajax', which is why it's doing it. So is there a way to also theme the return elements in my AJAX driven form, but only for my specific page? Hope that makes sense.
Comments
Maybe. Can you give a little
Maybe. Can you give a little more detail on what you are trying to accomplish?
Solved with custom theme callback for system/ajax
I'm sure you're way beyond needing the answer for this by now, but I thought it might at least be helpful for others dealing with the same problem.
The way I solved it was by creating a custom theme callback for system/ajax by using hook_menu_alter(). Here is an example code:
I hope this helps someone!
Super helpful!
This was very helpful, thank you!