1

I am wondering how I can attach a switch/ link from one view display to another view display within the same view. I can only think of messing around in the template files and hardcoding this navigation.

enter image description here view-mode-list

What is the best solution/ is there a better solution for that?

Update: both displays shall have a own url this for caching and possibility to link to a specific display.

myview/(default: display-table)
myview/display-table
myview/display-list
  • Use Quicktabs module – Minty Mar 18 '13 at 20:21
  • I fear quicktabs might be an overkill for that. I will wait for more answers – Andre Baumeier Mar 18 '13 at 20:44
3

Display Suite

A possible solution to this is probably utilizing display suite.

You could trigger a link using display suite & display suite extras to open different view mode. The drawback to this is that the user would have to load a different page.

Quicktabs

Another solution would be to load the two views as blocks and use quicktabs to display the two views in that tab format you require. The drawback to this solution is that you have two views loaded.

Views Header

At the top of your views, just add a header anchor to your other views page. This solution is best if you just have one view where this output is being displayed. Otherwise, it would be difficult to maintain duplicate views.

| improve this answer | |
  • actually I am fine with reloading that page. the content should not be preloaded. I update the question – Andre Baumeier Mar 18 '13 at 20:11
  • Well then your solution seems to be best suited to try display suite and display the view as a entity. – chrisjlee Mar 18 '13 at 20:15
3

There is the View modes module which does exactly what you need. However there is only a development version available.

If you prefer to avoid installing modules for small tweaks like this, you might want to create a simple switch in the views header.

You can do that either by adding a text area to the header of the view (notice this will require the PHP text filter to work properly), alternatively you can implement hook_views_pre_view to attach a header dynamically (-> better option).

For the link to retain page and filter values you will have to use the l() function along with drupal_get_query_parameters().

Take a look at the blog post I wrote for more details.

| improve this answer | |
  • enabling PHP text filter really should not be recommended. hook_views_pre_view to attach the header is the better option, but still - after all this time I think my option of creating a menu, putting links to each view page in it, and using context to add this menu to whatever area the view is showing up when the view is beeing viewed is a good solution, which doesnt require code at all and still uses all inbuilt solutions (menu trail etc) – Andre Baumeier Feb 28 '15 at 10:08
  • Context module is not inbuilt and displaying static links depending on url could be done with a simple (menu-) block, not requiring the Context module at all. However neither the context nor the block solutions will suit most use cases as they do not respect filters and page number - hence my answer. But since it's your question I guess you know what's best for you ;) – gbyte Feb 28 '15 at 17:16
-1

I actually found a good solution for this problem using the built-in menu system, providing menu links to these view pages and attaching the menu to the view using context module.

This works even better with Icon API

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.