A while ago I got Availability Calendar to work just fine. Went on to other things.
Recently, I've been using Page Theme module to theme panel pages with unique URLs. Today, I started to add some content to a content type not related to any specially themed pages. When I edited a month, say, February 25th, "FULLY BOOKED" and clicked save, I would receive an error upon viewing the saved page:
warning: Invalid argument supplied for foreach() in /Users/Cale/Sites/acquia-drupal/sites/all/modules/availability_calendars/availability_calendars.module on line 258.
I was using an older dev version, so I upgraded to 6x.1x-dev today. Error went away as I was able to edit Availability Calendar content successfully, BUT then noticed, after enabling this module, every page I had themed using Page Theme module immediately shut down and reverted back to my default theme.
I have made no changes to the Availability Calendar. I even tried with the 6x-1.5 version.. But again, my Page Theme module breaks down.
I don't know have a clue what's doing this but these seem two very unrelated modules. However, I cannot use this module if it is breaking down my Page Theme pages. Any help?
Thanks
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | 1076786.patch | 2.21 KB | fietserwin |
Comments
Comment #1
calefilm commentedComment #2
calefilm commentedMY FIX:
I don't know what I'm doing but the older dev version wasn't disabling my themes. So I went into the old availability_calendars.module file at availability_calendars/availability_calendars.module and replaced line 16 in the new file.
OLD
NEW
Now, I got my themes back. And the error is gone.
Comment #3
fietserwinOn porting the code to D7, I found that the hook_init() did contain some code that the original developer himself had doubts about (comment: can't find a better way to do this). So I looked for a better way of adding the css and came up with the following code for D7:
old: see #2
new
Can you test and review this patch?
Comment #4
nicholas.alipaz commentedfietserwin, the developer here. I have an issue with what you are doing via variable_get(). This does not account for when users are allowed to select their own theme for the site. Any ideas about that? We need to determine which theme is actually in use.
Comment #5
nicholas.alipaz commentedComment #6
fietserwinYou're right, but then I guess this can't be known in the init hook. The theme has not yet been initialized (when I was debugging through that piece of code I saw that our call to list_themes() was the first (the static inside had not yet been initialized). Moreover other modules exist that can change the theme in use on a per page/user or whatever basis.
So I think if you really want to solve this, you have to do it in a hook that's later in the process (or assure you're the last to init, as I guess that the choice of theme will be made in the init phase).
Some links:
- http://drupal.org/node/224333#custom_theme
- http://api.drupal.org/api/drupal/developer--globals.php/global/custom_th...
Comment #7
fietserwinFor D7 it turns out that theme initializing is done before hook_init (guess why). So, we may assume that in hook_init we have available the globals $theme_info and $base_theme_info. So for D7 I was able to rewrite this part cleanly:
D6 has the same globals, but we can not assume that they have been set in hook_init, However in a theme function they will be set. So,in D6, we could move this code to the theme_availability_calendars_node() function. In that case, it will not be rendered as often, only when necessary, so it may lead to another aggregation. How bad is that?
Comment #8
fietserwinConsidering:
- the difficulties we have in determining the actual theme that will be used on a given page (see comments #3, #4, #6, and #7)
- the fact that in the 6.x-2.x branch this problem has been removed by rewriting the styling stuff, so we don't do any theme specific includes anymore
- the fact that this errors only surfaces in some configurations (no single theme in use; modules changing theme in the init phase, ...???)
I am going to close this call as a won't fix.
Note that the 6.x-2.x branch will *not* suffer from this error. Thus if you are experiencing this issue, please upgrade to the 6.x-2.x branch (and don't forget to run update.php).