Hi,

I made some changes to your tvs module:
- I added hook_install, to call tvs_menu_alter after views_menu_alter, so that having taxonomy/term/% view enabled is no longer neccessary
- a core taxonomy/term page is displayed if no suitable view is found in taxonomy_views_switcher_get_view()
- a view with path: switch/vid/[vocabulary_machine_name] (in addition to switch/vid/[vid]), is handled (it's easier to get vocabulary machine name that vid)

I can provide a patch to your repository if you want (see http://drupal.org/node/707484)

CommentFileSizeAuthor
#2 suggested_changes-1138580-1.patch4.83 KBpgorecki

Comments

simg’s picture

Hey, thanks Przemysław, sounds cool :)
If you post the patch, I'll apply it (might take a week or so as I'm currently on holiday after a "fairly" busy 3 months)
Thanks :)

pgorecki’s picture

Status: Needs work » Needs review
StatusFileSize
new4.83 KB

Here's the patch + taxonomy_views_switcher.install file below:

function taxonomy_views_switcher_install() {
  // Taxonomy views switcher should run after Views,
  // so that TVS hook_menu_alter will override 'taxonomy/term/%' view
  $views_weight = db_select('system')
    ->fields('system', array('weight'))
    ->condition('name', 'views')
    ->execute()
    ->fetchField();

  db_update('system')
    ->fields(array('weight' => $views_weight+1))
    ->condition('name', 'taxonomy_views_switcher')
    ->execute();
}
simg’s picture

Thanks Przemysław. Have updated the repository.

I've also added the ability to specify a path of switch/tid[tid] or switch/tid/[term name] to allow different views for specific taxonomy terms.

The code now matches views in the following priority order (highest priority first):

1. Matches against the term id or name (switch/tid[tid])
2. Matches against the vocabulary id or machine name (switch/vid/[vid])
3. Matches against the request path (eg request_path() )

(The term name matching code is a bit weak as it uses just the name rather than the alias, but I was in a hurry and I'm not sure if anyone is going to use this functionality anyway?)

simg’s picture

Status: Needs review » Closed (fixed)