Hi,
First off - ThemeKey rocks! Thank you very much for all the hard work that went into this.
My feature request is to be able to change a theme based on a value of a field - specifically in my use-case, a user field. I saw the ThemeKey User Profile, but isn't that tied to their session throughout the entire site? What I'm looking for is the ability to say:
My name is Joe and I have a profile page on this site. There are a few themes available that I can choose so that when users visit my profile page on this site, they are presented the theme I chose in my profile.
I couldn't find anything on this (since it's partly dependent on the first part) -- can you then use that same logic of saving the profile field value and pull that over to views that have contextual filters for that user? For example:
Joe's profile is Theme1. When I visit a 'View' that lists blog posts by him (that uses contextual filters) that same setting from his profile is also drawn into that View, single-node pages, etc.
Thanks!
Comments
Comment #1
mkalkbrennerThe problem is that hook_custom_theme() runs before hook_init() in drupal's boot process. Therefor it's to hard to access fields. At this stage you don't have user or node objects.
Maybe drupal 8 is smarter ...
Comment #2
m4oliveiSure, but why not just node_load based on the node id in the URL, and then compare against the result?
I notice you have a bunch of comments throughout the themekey.node.inc file stating:
"node_load() must not be called from hook_init(). Therefore, we have to execute SQL here"
Why is that? Does that still apply in Drupal 7? Even if it does, could you get the data using EntityFieldQuery?
Comment #3
mkalkbrennerThe comment has to changed: "node_load() must not be called from hook_theme(). Therefore, we have to execute SQL here"
But the rule is still the same: if you node_lode() before or within hook_init() than it could happen that an incomplete node gets cached by drupal and the page breaks.
But EntityFieldQuery might be an option. It didn't exist in the early drupal 7 days ...
Comment #4
m4oliveiYeah, EntityFieldQuery may be a way to get this feature in.
In my case, I'm just going to implement hook_custom_theme() in my module. The other issue I found when I pursued using themekey's api, was that I wanted an in_array operator, but themekey doesn't have that. Another cool feature would be the ability to define new operators. But I digress :P
Comment #5
mkalkbrennerI will have a look at entity queries.
But feel free to come up with some patches. Extending the properties is possible ...
Comment #6
mkalkbrennerSupport for field values has been committed to 7.x-3.x :-)
http://drupalcode.org/project/themekey.git/commit/1b15c51
Testers are welcome!