Hello and thanks for your work on this module!

Currently all of the HTML output is handled within functions. The inner HTML has been moved into a theme function (#2473897: Give themes the ability to theme site alerts.), which is an improvement, but a front end developer would still have to override that function in order to customize the output. I've moved the HTML into template files so that themers can simply copy the files into their own themes to be edited directly.

Two template files are provided:

site-alert.tpl.php - contains the inner html
site-alert-wrapper.tpl.php - contains the outer html <div class="site-alert"></div>

This change should have zero affect on existing installations, even where the theme function is already being overridden.

Thanks!

Patch to follow.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

othermachines created an issue. See original summary.

othermachines’s picture

As promised. I've also added an empty update function to force a necessary cache clear.

othermachines’s picture

Status: Active » Needs review
cecrs’s picture

I think I like this approach. I will review and do some testing on sites with existing installations, the patch is much appreciated! :)

othermachines’s picture

FileSize
5.4 KB
1.88 KB

Hi, @cecrs. That's great to hear. :)

Today I fussed with this a bit more and made a couple of changes:

1. I removed the function theme_site_alert() since it wasn't actually doing anything and replaced it with template_preprocess_site_alert(). (It's still OK if themes have implemented their own THEME_site_alert() so updating shouldn't be a problem.)

2. This one was a bit tricky. I couldn't get Drupal to recognize the site-alert.tpl.php template when it was in the admin theme (!). After quite a lot of wrangling I discovered that even though it was being registered properly, the callback at ajax/site_alert was always loading the default theme. I resolved this by passing the theme and token values contained in Drupal.settings.ajaxPageState to a theme callback function specified in the hook_menu() definition. Although it works perfectly I'm not entirely sure this is the proper solution so wouldn't mind some feedback from someone who knows more about the ajax API than I do.

Here is some d.o. documentation on the theme callback function: ajax_base_page_theme()

Thanks!

  • cecrs committed fd45879 on 7.x-1.x authored by othermachines
    Issue #2789657 by othermachines: Make alerts easier to theme for non-...
cecrs’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.