Hi guys,
I wanted to report a suspicious behaviour I encountered recently on the latest dev version [7.x-3.5+21-dev (2012-10-31)].
In any views with page display, with a required path configured, for example: node/%/custom_name
Under Page Settings > Menu:
(To display the Page: Menu item entry dialog form)
Select Menu tab for the menu item Type.
[This should set the menu item to be displayed as a menu local task]
In this particular form, it is possible to select to:
>Displays the link in contextual links
by marking as checked the Context checkbox (that is only displayed in this particular case).
See attached screenshot: views-page-display-menu-tab-overriden-contextual-link-0.jpg
Currently, it seems that if this setting is selected/checked, the menu local task/tab doesn't display anymore and the menu link is only displayed in contextual links (which prevents from displaying both: menu local task and contextual link).
This particular behavior comes from the code at:
/plugins/views_plugin_display_page.inc, line 156:
$items[$path]['context'] = MENU_CONTEXT_INLINE;
which seems to override the defaults from line 146:
$items[$path]['type'] = MENU_LOCAL_TASK;
since the context property is not set.
After checking what the node.module does, I was brought to:
node.module, lines 2027, 2028 [drupal-7.16]
'type' => MENU_LOCAL_TASK,</strong>
'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
which led me to think that we would perhaps also need to add a menu page context in order to display the Tab menu item (menu local task):
MENU_CONTEXT_PAGE
So at this point I would like to suggest the following options to try to approach this issue[feature request]:
1 - Allow user to select whether to display both: menu tab (local tasks) and contextual link.
Add another setting, such as a checkbox, to allow users to select whether to hide or display the menu tab, which would allow user to select any of the following behaviors:
- menu local task overriden by contextual link: both checkbox checked
- menu local task and contextual link: Hide menu tab unchecked
a. Addition of a new form setting:
/plugins/views_plugin_display_page.inc, line 391:
[setting variable name: contextpage]
$form['menu']['contextpage'] = array(
'#title' => t('Hide menu tab'),
'#suffix' => '</div>',
'#type' => 'checkbox',
'#default_value' => !empty($menu['contextpage']),
'#description' => t('Only display menu item entry in contextual links. Menu tab should not be displayed.'),
'#dependency' => array(
'radio:menu[type]' => array('tab'),
'edit-menu-context' => array(1),
),
'#dependency_count' => 2,
);
b. Update of the logic:
/plugins/views_plugin_display_page.inc, line 156:
$items[$path]['context'] = (empty($menu['contextpage']) && MENU_CONTEXT_PAGE) | MENU_CONTEXT_INLINE;
when $menu['contextpage'] is not selected, the menu tab and the contextual link can be displayed at the same time.
If the checkbox is marked as checked (selected) then the menu tab is overriden by the contextual link (menu tab is hidden).
Please find attached a patch to sum up these changes: views-page-display-menu-tab-overriden-contextual-link-0.patch
2 - Modify current behavior to display both by default [menu tab (local tasks) and contextual link]
I haven't followed much of the discussions related with the current implementation for menu tab/contextual link($menu['context'], /plugins/views_plugin_display_page.inc, line 155), but perhaps allowing users to display both as default could be a better alternative than preventing menu tab from displaying by default:
/plugins/views_plugin_display_page.inc, line 156:
$items[$path]['context'] = MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE;
As a minor inconvenience, in this case, menu tab could be considered to be hidden with CSS.
I guess there would be other approaches to respond to this issue, so I would certainly be glad to hear your feedback on this.
Could you please let me know if I overlooked or missed anything in the current views module (and its API), in terms of whether this (displaying menu tab along with contextual link) would be doable already with existing hooks/settings?
But for this particular use case, I haven't been able to find any appropriate existing solution/answer.
Please let me know if you would have any questions on any points/code/aspects mentioned in this ticket, I would surely be glad to provide more information.
I would greatly appreciate if you could take a bit of time to take a look at the patch and give me your feedback on this feature request.
Feel free to let me know if you would have any questions about the code or any other aspect of the patch, I would be glad to explain in more details.
Thanks in advance.
Comments
Comment #1
DYdave CreditAttribution: DYdave commentedChanging status for review.
Comment #2
jonhattanThe "context" checkbox was added in #1128088: Provide a way to create contextual links from local task menu items. It seems to me it was not intentional to hide the menu tab. Indeed hidding the menu tab is baffling since you're asking views to create a menu tab after all.
DYdave's patch works great!
Comment #3
DYdave CreditAttribution: DYdave commentedHi jonhattan,
Thanks you so much for getting back to me on this with a very positive feedback.
I had assumed this feature request fell in the abyss of the Views tracker and no one would actually notice this to give it some testing and a review.
I would greatly appreciate if this could get committed, as I would also agree with you that it would further refine the work that was done around contextual links at #1128088: Provide a way to create contextual links from local task menu items.
Feel free to let me know if you would have any further questions, comments, issues, concerns, suggestions, recommendations or objections on this feature request in general, I would be glad to provide more information or explain in further details.
Any further comments, feedback, testing, reviewing and reporting, would be highly appreciated.
Thanks again to all in advance for your support, comments, replies and feedback.
Cheers!
Comment #4
dawehnerEvery option available should be documented as part of views_plugin_display_page::option_definition() which is missing here.
Comment #5
DYdave CreditAttribution: DYdave commentedHi guys,
I'm so grateful I could get your attention on this and certainly wouldn't want to let this stall any longer.
Thanks a lot @dawehner for your feedback, review and clear answer.
Please find attached to this comment the updated patch based on the initial suggested version, against views-7.x-3.x at 74b42a9:
File named: views-page-display-menu-tab-overriden-contextual-link-1831094-5.patch
Added in
views_plugin_display_page::option_definition()
definition for'contextpage' => array('default' => 0),
to initially display both menu tab and contextual links (so Hide menu tab unchecked by default).I would greatly appreciate if you could let me know if I missed or overlooked anything in this re-rolled patch, I would certainly be glad to work some more on the patch and take into account further reviews, comments or objections.
Feel free to let me know if you would have any further questions, comments, issues, concerns, suggestions, recommendations or objections on this feature request in general, I would be happy to provide more information or explain in further details.
Any further comments, feedback, testing, reviewing and reporting, would be highly appreciated.
Thanks again to all in advance for your support, comments, replies and feedback.
Cheers!
Comment #6
dawehnerIn a perfect world you could specify it to be 'bool' => TRUE, and FALSE
I'm wondering whether it would be possible to come up with a better name for this variable? Just from 'contextpage' it seems hard to figure out what this is for.
Comment #7
DYdave CreditAttribution: DYdave commented@dawehner:
Thanks so much once again for the prompt reply.
No problem, I'll get the type changed in the form and in the
option_definition()
.As for the variable name, I'm not so sure either (because it could also easily get quite long). What about:
Any other recommendations, comments, suggestions, would be highly appreciated.
As soon as I could have your approval on a variable name, I should be able to get the patched re-rolled.
Feel free to let me know if you would like to look for more variable name suggestions, I would be glad to help finding more possible options.
Thanks very much in advance for your reply.
Comment #8
dawehnerSorry for the delay.
Mh this logic seems to be hard to understand? MENU_CONTEXT_PAGE is just a 1, so cant' we do this simpler?
What about context_only_inline?
Comment #9
DYdave CreditAttribution: DYdave commentedHi dawehner,
Thanks again so much for the prompt and clear feedback.
I have taken all your comments/suggestions into account and re-rolled the patch.
Please find attached to this comment the updated patch, against views-7.x-3.x at 74b42a9:
File named: views-page-display-menu-tab-overriden-contextual-link-1831094-9.patch
with the following changes:
1 - Changed variable name:
contextpage
tocontext_only_inline
, as suggest in #8.2 - Changed type of variable to bool with FALSE:
'context_only_inline' => array('default' => FALSE),
as suggest in #6.
3 - Changed the logic as suggested in #8:
$items[$path]['context'] = empty($menu['context_only_inline']) | MENU_CONTEXT_INLINE;
Feel free to let me know if you would have any further questions, comments, issues, concerns, suggestions, recommendations or objections on this updated patch, I would be happy to provide more information or work on the patch again if necessary.
Any further comments, feedback, testing, reviewing and reporting, would be highly appreciated.
Thanks again to all in advance for your support, comments, replies and feedback.
Cheers!
Comment #10
dawehnerThat's looking great, for sure.
This is a small adaption to make the code more readable. Additional we might should ask the UX team in D8, how we gonna do that non-confusing, because currently you basically say: I want a tab, no I don't want one :)
Comment #11
DYdave CreditAttribution: DYdave commentedHi dawehner,
Thanks again very much for your help reviewing the patch and revising the code.
At this point, I'm not exactly sure how I could potentially help moving this forward.
Feel free to let me know if you would like me to discuss or suggest different options for this to be improved or integrated in Drupal 8, I would certainly be glad to help you work on this.
As a side note and I think you would understand, I would hope/wish that this could potentially be committed as soon as possible. In particular, I would assume the discussion for a D8 port of this feature could probably take a while..... so if possible, it would be great if we could perhaps go ahead with this first in D7, then continue discussing for D8.
Any further feedback, comments, ideas, issues, questions, reviews, testing, objections, recommendations or suggestions on any aspects of this ticket or patch would be highly appreciated.
Thanks very much to all for your great work, replies, comments, reviews and testing.
Cheers!
Comment #12
dawehnerWell one question is: Do you agree with the changes in made in #10? If yes I think this is ready to go in Views for Drupal 7.
Once this is committed we will move this issue to Drupal 8 and continue to work on that.
Comment #13
dawehnerThanks for your long work on that. Committed and pushed to 7.x-3.x
Comment #14
DYdave CreditAttribution: DYdave commented@dawehner :
Thank you so much for committing this, your great follow-up, all your suggestions and great reviews of the initially submitted patch.
Thank you also for suggesting to port this to D8 and I will certainly try to start working on that when I can.
Just wanted to track here a few useful hints you gave me on IRC to get me started (or in case anyone else would like to catch up):
I will certainly get back to you as soon as I have further questions or more substantial information to discuss.
In the meantime, feel free to let me know if you would have any particular questions, comments, issues, suggestions, recommendations, ideas or concerns on any aspects discussed in this ticket, I would surely be glad to provide more information or explain in more details.
Thanks again to everyone for your interest, great feedback and reporting.
Cheers!
Comment #15
dawehnerOne request I would like to have: stop using < strong > in your posts :)
Comment #15.0
dawehnerstyle edit
Comment #16
almaudoh CreditAttribution: almaudoh commentedIs this still needed in D8?
Comment #19
catch