I just realized that none of Taxonomy properties work (tid and tid and childs).

Situation :
What i'm trying to do is to display a different theme when user visits nodes which have an special taxonomy term. The nodes have three vocabularies, two single select regular vocabulary and one tag type.

What i did :
I used the term id of the first vocabulary in the node with taxonomy:tid_and_childs property and selected a different theme.

Expected behavior :
I expected to see that theme instead of the default one when i visit the node but it shows me the default theme.

What i've already tried :
I tried various combinations but nothing helped. is this a bug or i'm missing something ? (Used to work on 1.x)

PS : Thanks for all your hardworks on 2.x version, it's much easier to use and much more flexible than before. Also thanks for the awesome documentation ;). Well done

Comments

mkalkbrenner’s picture

Could you please turn on ThemeKey Debug and activate "Show ThemeKey properties values" and "Trace ThemeKey rule switching". Please post the output of the page where theme switching doesn't work like expected.

sinasalek’s picture

The logs look strange, it shows no match for the one that works and says it uses the default theme but it users the matched theme. it shows match for the second one doesn't work.

This one uses path property and works : http://salek.ws/projects/drupal/works.txt
This one users tid_and_childs and does not work : http://salek.ws/projects/drupal/not_works.txt

Nice debugging feature BTW ;)

mkalkbrenner’s picture

Looks strange. How are tids 307 and 104 related?

sinasalek’s picture

They're from different vocabularies, 307 is a tag

sinasalek’s picture

Note that i used to work after this #584982: Does not respect hierarchy of terms

sinasalek’s picture

@mkalkbrenner I traced the code and i'm sure that it detect the taxonomy correctly.
The problem is with assigning the theme. I'm also sure that it fill $custom_theme with the
correct theme. but i don't know why it doesn't work!!
Any kind of tips is highly appreciated :)

sinasalek’s picture

mkalkbrenner’s picture

if $custom_theme is set correctly there could be two reasons for your issue:
1. a different module that overrides $custom_theme after ThemeKey. Can you debug it's value in function init_theme() in theme.inc?
2. a different module that initializes the theme engine to early. Try this: http://drupal.org/node/681358#comment-2470222

sinasalek’s picture

Thanks that helped,
There is a conflict with Revisions RSS module, least expected!, i'm trying to figure why it's happening.

mkalkbrenner’s picture

Please post some details when you figured them out. We already improved the compatibility to some modules in the past ...

sinasalek’s picture

I found it, the following code causes this issue.
Solutoins
- Commenting drupal_add_feed... !!
- Disabling revisions_rss modlue !!
- And changing the default weight of themekey module to -1 to decrease the possibility of conflicting with other module in future. As you know most modules' weight is 0 so it can happen again.

There is something i don't understand , why calling drupal_add_feed prevents themekey from setting the theme?

<?php
/**
 * Implementation of hook_init().
 */
function revisions_rss_init() {
  // Expose node feed on node view page.
  if ((arg(0) == 'node') && is_numeric($nid = arg(1)) && is_null(arg(2)) &&
      ($node = node_load($nid)) && revision_rss_check_type($node) &&
      user_access(REV_RSS_PERM)) {
    
    drupal_add_feed(url("node/{$node->nid}/revisions/rss"),
                    t('Updates to "@title"', array('@title' => $node->title))
    );
    
  }
}
?>
mkalkbrenner’s picture

There're two bugs in module revisions_rss:
It's not allowed to call node_load() within hook_init().
You must not call function t() within hook_init() (because this one starts the the theme engine).

See:
#582382: Blog Theme causes Fatal Errors in other modules, due to bad hook_init() implementation
#684868: Imagecache breaks, avoid node_load() in hook_init()

@sinasalek: Will you open a new issue at revisions_rss or should we move this one?

sinasalek’s picture

Title: Taxonomy properties don't work » ThemeKey does not work properly due to the conflict with Revisions RSS
Project: ThemeKey » Revisions RSS
Version: 6.x-2.0-beta7 » 6.x-1.0
Component: Code / API » Code

I understand now,
I think we should move this, it's good example of what issues it causes. I also changed the title.

Thanks for your help @mkalkbrenner.

sinasalek’s picture

Revisions RSS maintainers please read comment #12.

Thanks

sinasalek’s picture

StatusFileSize
new1.6 KB

I've decided to write the patch.
This patch replaces node_load with simpler alternative, It also fixes a performance issue. The previous code used to call node_load for almost every page now it only calls it if it when all other conditions met.

sinasalek’s picture

Status: Active » Needs review
alexjarvis’s picture

Assigned: Unassigned » alexjarvis

sinasalek/mkalkbrenner, thank you for bringing this to my attention. I am working on a fix now and hope to have an update for you to try tomorrow.

alexjarvis’s picture

Status: Needs review » Fixed

Release 1.5 should fix this issue. I migrated from hook_init to hook_nodeapi, which should improve compatibility and performance. Give it a try and let me know if you continue to have trouble.

sinasalek’s picture

Awesome , thanks

Status: Fixed » Closed (fixed)

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