It was by looking at your code that I was able to easily figure out how to create a Context plug-in. Thanks for that.

Are you interested in another plug-in? It's dead simple (but useful IMHO) and should really be grouped with other plug-ins. All it does is add a condition for selecting vocabularies. It's useful, for instance, if you have set a condition for a node type and want the same context to apply when a taxonomy term is clicked on from within the node content.

Let me know and I'll post it here.

Cheers--

CommentFileSizeAuthor
#2 cep_taxonomy_vocabulary.tar_.gz1.09 KBothermachines

Comments

hadsie’s picture

Not sure I totally get it yet. So the condition would be if a specific taxonomy term is set on the node that you're currently viewing?

But ya, post it up here for sure.

othermachines’s picture

StatusFileSize
new1.09 KB

Not quite. The condition is vocabulary-specific rather than term-specific. For example: I'm viewing a news article. Since there is a menu context set for content type 'article', "News" is active in the menu. However, when I click on a linked tag within the article I lose the menu context and "News" is no longer active. This allows me to set the vocabulary as a condition so that I can retain menu (or other) context when taxonomy links are followed.

It seems strange to me that there isn't already a plug-in out there for something so basic. Or, if there is, I haven't found it.

Plugin attached...

hadsie’s picture

Status: Active » Needs review

Ahh, gotchya. Ya, I think there may actually be other ways to handle this instance in most use cases, but I can definitely envision a case where you would want it. I'm going to add this into the next release.

Just to confirm, this only ever apply to full page nodes though right? Or would it work on a teaser listing too?

hadsie’s picture

Sorry, just read through the code in more detail and it looks pretty good, I've just made a couple minor changes to it that are listed below. I originally misinterpreted this as to be node related, but actually it's specific to taxonomy listing pages. This couldn't be accomplished by using the Path condition as you actually need to inspect the tid.

* I added $this->condition_used() to the execute method and removed the $map stuff in the hook_init as I believe that's a bit more reliable. The $map stuff didn't work at all for me in fact, I believe perhaps because Drupal was using a cached version and this plugin wasn't yet registered. (I'm not actually 100% about this as I haven't used the map technique before, but probably better to have a simpler init() function).
* I updated the description in the .info file to hopefully be a bit more descriptive ;-)

I think that's it. It's in git now.

hadsie’s picture

Status: Needs review » Fixed

Marking as fixed as it's available now. Just created a dev release.

othermachines’s picture

Status: Fixed » Closed (fixed)

Awesome! Glad to hear it. I'll mark this as closed.