0

In my question Most maintainable way to make page with one top half and alternative bottom halves selected by tabs?, I've asked about making a page with, as the title says, alternative bottom parts selected by tabs. There are various modules (Quick Tabs, Panels Tabs, etc.) that do tabs. But I have found that core Drupal itself has a feature for adding tabbed menus to Views pages. It's explained for example at Randy "Wilson" Brown's Drupal: How To Add A Tab To A Views Page. Why only to a Views page?

And — suppose I try to use these menus to select between things that really aren't views. For example, suppose I try to set up a page that has three tabs called "Photo 1", "Photo 2", and "Photo 3", each of which selects a different photo of my cat. I don't know whether I can make the views menus do this, but should I even try? Or is it likely to lead to problems, for example by being hard to do and maintain?

(Added a few days after posting) I'm adding the paragraphs below to clarify the spirit of what I'm asking.

I've coded with many languages and libraries where, to get a job done, you must "pervert" them because they lack the features needed to do the job cleanly. One example is passing primitive types by reference in Java. Suppose you want to write a method that takes an 'int' parameter and gives it a new value. You can't do that cleanly, because Java lacks call-by-reference for primitive types. But you can fudge it by giving your method an integer array parameter and passing your 'int' in an array. It works because arrays are compound entities, and Java passes those by reference. But it's bad, because arrays are intended for storing sequences, and you're misusing them for something else. It makes the code harder to read.

How does this relate to Drupal? I've come across several articles, in blogs and elsewhere, which appear to be doing the same kind of thing with views. For example, there's a post by Ron Golan at https: //www.urbaninsight.com/2013/11/01/views-menu-tabs-quick-guide which uses views to tab between different tabbed pages about a coffee grinder. One of these tabbed pages is a photo of the coffee grinder. In my mind, that's not a "natural" thing to use views for, because they are, in essence, database queries. And you don't need database queries in order to place one photo whose identity you know in advance.

Therefore, I suspect Golan is using views because he wanted their tabbed menus. When I see something like that, I have to think like an engineer and ask: somebody clever thought this trick worth using. Why? Why didn't he use a more direct technique? Is it because the trick, though perverse, is less risky than other techniques? For example, because it will not collapse if I update my Drupal or my jQuery. If I didn't ask such questions, I'd be betraying my client, because I'm ignoring information that might indicate dangers in some of my tools.

  • If you add some style (paragraphs, bold, white spaces etc.) to the question it would be more readable and understandable. – herci Aug 7 '15 at 17:02
  • " Why only to a Views page?" Is like asking why water is only in rivers. Can't have an answer, because limits stated in question simply doesn't exist. He talked about views so he mentioned views, that's all. – Mołot Aug 7 '15 at 17:06
  • Mołot, I've added more information about why I'm asking this. Briefly stated, some people appear to be using views not as database queries, but because they provide tabbed nenus. But there are other tools, seemingly better, for providing tabbed nenus. So why would someone use views? Is it because there are risks in the other tools? If so, I need to know. – Jocelyn Ireson-Paine Aug 10 '15 at 12:24
2

This functionality is built into the Drupal menu system but is not exposed as a configurable option through the web interface by Drupal core. You would normally have to write some code that implements hook_menu to accomplish this.

Views happens to give a user interface for this functionality, so some people will take advantage of that to do things that maybe aren't best done in Views just because it lets them do it without having to touch code. I should note that Page Manager and Panels also give you configuration that let you do this through the UI and that would be a better way to achieve this if you have pages that aren't naturally Views.

  • Thanks Aaron. That's exactly what I wanted to know (and what I suspected, but needed to get confirmed by an expert). I tried to upvote your answer, but don't have enough reputation. – Jocelyn Ireson-Paine Aug 10 '15 at 19:01

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.