Just curious if this module could be used to switch the theme displayed on a node based on that node's author (lets say I add a select field to the user node for the author to choose one of 20 different themes to be displayed when users are viewing their content).

Comments

mkalkbrenner’s picture

Project: ThemeKey » ThemeKey Properties
Version: 6.x-1.x-dev » 6.x-1.0
Component: Code / API » Code
Category: support » feature
mkalkbrenner’s picture

Project: ThemeKey Properties » ThemeKey
Component: Code » User Interface

Something similar is already available:
1. On /admin/settings/themekey/settings turn on "Discover all node properties for selection"
2. Use property node:uid to select a theme according to the author of a node

Now the feature request is to allow the author himself to select a theme for all his nodes. Probably in his profile settings ...

mkalkbrenner’s picture

Title: Switch theme based on author of node? » allow the author himself to select a theme for all his nodes
Version: 6.x-1.0 » 6.x-1.x-dev
mkalkbrenner’s picture

Version: 6.x-1.x-dev » 6.x-2.0-alpha2
mkalkbrenner’s picture

Version: 6.x-2.0-alpha2 » 6.x-2.x-dev
sansui’s picture

I totally forgot about this thread :) But the other thread I created still stands

So is it not currently possible to create a module or addition that would do this in combination with themekey?

Basically:
1.) User selects themekey setting in profile
2.) Helper module creates new themekey rule for selected user/theme
3.) All users now see the author's selected theme when viewing that author's content

sansui’s picture

What I'm thinking of doing is creating a small module to provide a new tab and form in the user profile, that lists the available themes on the site with checkboxes for the users to select from. What I'm trying to figure out is how I should update the themekey_properties table. I found the function for themekey_rule_set - can/should I use this vs. updating the table directly? In my configuration, there would only be one rule per UID, so it seems like I could just update the table directly myself

Then again, I'm not a programmer, so maybe I'm missing something important :)

mkalkbrenner’s picture

Assigned: Unassigned » mkalkbrenner

This feature has to be implemented using ThemeKey UI to add a nice theme selection box to the users Profile (maybe as tab).
Than we have to introduce a new "static rule" using ThemeKey UI's API.

Everything we need is already in place. Please do not touch the database like you described above.

mkalkbrenner’s picture

Status: Active » Needs review
StatusFileSize
new8.97 KB

It took me some hours but here is the patch. (BTW it was impossible to implement this feature on ThemeKey 6.x-1.x architecture.)
After applying this patch (or download ThemeKey 6.x-2.x-dev > 2010-07-17) you can activate the feature like this:

1. Install (or update) ThemeKey UI.
2. Visit "/admin/settings/themekey/settings" and save the settings. That is necessary to force ThemeKey to scan for new properties. (I hope to provide a better solution for ThemeKey 6.x-3.x)
3. Activate "Show theme option in user profile" at "/admin/settings/themekey/settings/ui".
4. Move the static rule "themekey_ui:node_author_triggers_theme" to the postion it fits your needs at "/admin/settings/themekey".
5. Adjust the role settings for "assign theme to own nodes" at "/admin/user/permissions".
6. Test this new feature and create a tutorial like "Rule Chaining: Using a special theme for content creation depending on user roles" which you can find at "/help/themekey" => tutorials ;-)

Feedback is welcome!

sansui’s picture

Wow, that was some quick work - I'll be back where I can test this out in a couple hours, so I will check this out ASAP for feedback and more :)

sansui’s picture

I was able to successfully patch and update my themekey module, enable the user interface option, and select the new theme for a test user. I tested with both the admin account and a sub user account, swapping themes multiple times and checking the view from each account.

When viewing that user's content, the theme changed as expected. Very nice work :)

mkalkbrenner’s picture

Component: User Interface » Documentation
Assigned: mkalkbrenner » Unassigned
Category: feature » task
Status: Needs review » Needs work

waiting for documentation

sansui’s picture

I'll put together something tomorrow with some screenshots. There is some wording that needs to be fixed in admin interface

Under admin/settings/themekey/settings/ui, the help text for the checkbox "Show theme option in user profile" should say something like "Assign themes from user profile. This will show a 'Theme' section under "edit" in user profiles.

Currently it says same as create/edit node forms.

mkalkbrenner’s picture

I adjusted the description. Thanks for the hint.

sansui’s picture

Something else I noticed was if a user selects a theme, and then you disable the theme in theme selection - the disabled theme is still shown for that user's content. That's not a problem for my functionality, but thought I would mention it in case it should behave differently (like defaulting to main theme)

sansui’s picture

StatusFileSize
new14.03 KB
new10.31 KB

Wasn't sure what format you wanted me to give you the tutorial in, but I just pasted this into my themekey_help.inc based on your existing tutorial example. Images attached in this post

  $form['themekey_help_tutorials']['Allowing users to select a theme for content they create'] = array(
    '#type' => 'fieldset',
    '#title' => t('Allowing users to select a theme for content they create'),
    '#collapsible' => TRUE,
    '#collapsed' => $form['themekey_help_tutorials']['#collapsed'],
  );

  $form['themekey_help_tutorials']['Allowing users to select a theme for content they create']['item'] = array(
    '#type' => 'item',
    '#value' =>
'<p>' . t('In this tutorial you will learn how to enable users to select a theme for content they create.  For example, if you would like each of your bloggers to display their own theme on each of their blog entries, this tutorial will allow you to grant this option.</p>') .
'<p>' . t('First, you must enable any themes you would like available from under ').l('admin/build/themes','admin/build/themes').t(' (Administer -> Site Building -> Themes)</p>') . 
'<p>' . t('Once you have enabled your themes, navigate to ').l('admin/settings/themekey/settings/ui', 'admin/settings/themekey/settings/ui').t(' (Administer -> Site Configuration -> Themekey -> Settings -> User Interface). You will see a checkbox for "Show theme option in user profile".  Click on the checkbox and save your settings.</p>').
'<p>' . '<img src="' . $img_path . 'themekey_user_profiles_2.png" alt="' . t('Enabling theme selection in user profiles') . '" style="border:solid #d4e7f3 2px;" /></p>' .
'<p>' . t('Next, you must grant permission to the roles that you would like to be able to change themes for their own content.  Navigate to ').l('admin/user/permissions','admin/user/permissions').t(' (Administer -> User Management -> Permissions) and check the boxes for "Assign theme to own nodes" to all roles you want to enable this option.</p>') . '<br />' .
'<p>' . '<img src="' . $img_path . 'themekey_user_profiles_3.png" alt="' . t('Enable correct permissions to use themekey for your users') . '" style="border:solid #d4e7f3 2px;" /></p>' .
'<p>' . t('Once you have done this, your users can log in, navigate to My Account -> Edit and a new option will appear under their account settings.  A full select list of your enabled themes will appear for them to select from.  Once they have chosen a new theme, any node that is authored by this user will display the theme they have selected. </p> ') . 
'<p>' . '<img src="' . $img_path . 'themekey_user_profiles_4.png" alt="' . t('ThemeKey rule chain that switches to different themes on content creation forms for different user roles') . '" style="border:solid #d4e7f3 2px;" /></p>' .
'<p>' . t('Have Fun!') . '</p>',
    );

?>
sansui’s picture

StatusFileSize
new5.81 KB

Missed the third image attachment in the previous post

mkalkbrenner’s picture

@ #16 Sansui:
It works in my test setup. Maybe this could be caused by page caching. See #812114: Support for page caches (internal and external like 'Boost').
What happens if you clear the cache?

sansui’s picture

Coming back to this post after a while :)

I've noticed that in the account area, if you have multiple pages under "edit" that are added by other modules (for example, I have a billing module that has an additional page there), then the selection fieldset for themekey shows up in these other pages as well

It's a small detail, certainly not critical, but thought I would point it out :)

vlnm’s picture

Is it normal, that the feature described in this issue doesn't allow to change list pages of a blog (for example with url like http://mysite.com/blogs/coolblogger). It seems to be pretty expectable for a user to be able to control appearence of such pages, not only of content pages, isn't it?

Or, maybe I've done something wrong installing and setting up ThemeKey?

mkalkbrenner’s picture

This feature only affects nodes.
But as admin your able to set up a rule that sets a theme for this url.

vlnm’s picture

Yes, I can do it manually. But if there are dozens of users on my site and each of them has a different theme it would be a very boring job.
Can you, may be, guide me a bit of how to extend current rule themekey_ui:node_author_triggers_theme to apply user-chosen theme on list page too? I’m familiar with php but couldn’t understand how to do it with ThemeKey from the first attempt.

mkalkbrenner’s picture

Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

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