I have a group panel panes common for several pages. I'm trying to refactor them in a mini-panel for ease of maintenance. I run into difficulties with passing taxonomy term through context. I need an optional context so I can pass it on one panel page and skip on another. Unfortunately, contexts tab of mini-panels UI has quite a strange behavior. If I try to add an optional context I get a form which requires me to select an entity id. I guess, it's a default argument, but I don't need one. Moreover, if I select a random term and finish creating a mini-panel I can't select which context to pass to it when I add it to parent page.
If I add a required context to mini-panel, all seems to work, but I need an optional one.
Comment | File | Size | Author |
---|---|---|---|
#10 | panels-1588212-10.patch | 1.43 KB | geek-merlin |
Comments
Comment #1
akamaus CreditAttribution: akamaus commentedComment #2
stevectorI made some mini-panels context-optional on a client project a few months ago in a somewhat hard-coded fashion. I'll dig out that code and work on converting it to work generically.
Comment #3
diwant CreditAttribution: diwant commented@stevector Can I help you dig for it? I need this too, but I'd like to see how you did it since that'll save me some lurnin'
Comment #4
stevectorThe alter approach I used looked like this:
I'm changing the title of this issue because this is a doable patch and there is already a TODO in the code for it: http://drupalcode.org/project/panels.git/blob/refs/heads/7.x-3.x:/panels...
I'm not sure when or if I'll have time to work on such a patch.
Comment #5
stevectorThe patch should just be a form alter on the required context form to add an "optional" checkbox. Then a conditional check for that setting in _panels_mini_panels_mini_content_type_content_type().
And I suppose there are UI concerns around how confusing it'd be to have a "required" context be optional.
Comment #6
stevectorHere's the patch. Perhaps the UX concern of required vs. optional could happen in a follow up issue.
Comment #7
diwant CreditAttribution: diwant commentedIt works for me, good job! I patched 7.x-3.3 and it applied and worked there.
Comment #8
diwant CreditAttribution: diwant commentedI'll specify what I tried: I made 2 minipanels with optional contexts, and each showed the id of the contextual argument entity as content. I then placed them in a container panel. One of the 2 got fed the context and the other didn't. Worked as I would expect where they both could be added to the panel, and he first just didn't show it's content (the one that didn't get it's optional context).
Comment #9
merlinofchaos CreditAttribution: merlinofchaos commentedThe form alter is too permissive, and it will cause the [] optional checkbox to show up in places it shouldn't. For example, add a 'string' context to any panel page, and you'll see that checkbox, with mini panel specific language.
I actually think the checkbox should just be attached to all required contexts in CTools, though, so I don't really like the form alter as a patch here.
Comment #10
geek-merlinPatch flying in, implementing merlins hint:
* one patch for ctools with the optional-checkbox only for required contexts.
ui text similar to optional-checkbox of views-content argument input.
* one patch for panels
please test so we can get this in!
Comment #12
geek-merlinPatch against current dev!
Comment #13
geek-merlinAnd tell the bot!
Comment #14
geek-merlinComment #15
geek-merlinComment #16
geek-merlinComment #17
geek-merlinOK now that the bot gave green lights please do some manual tests.
remember: you need both:
* panels-1588212-10.patch
* ctools-1588212-11.patch
Comment #21
geek-merlinIt looks like the ctools patch and the panels patch should have their own issue, so created #2405187: Add "optional" checkbox for required contexts for ctools.
So ploease ignore the ctools patches here, the patch to commit is the panels patch i just requeued.
Comment #22
SocialNicheGuru CreditAttribution: SocialNicheGuru commentedThis works.
Comment #23
geek-merlinso the green panels patch from #10 is rtbc as of #22.
sorry again for the confusion by mixing projects.
Comment #24
japerryThe upstream ctools patch got in, this one looks good too. Committed.
Comment #27
geek-merlinThis breaks existing sites if we do not fix #2399313: Relationship silently left out if it has optional required context
Comment #28
sylus CreditAttribution: sylus commentedI created a follow up issue to this one so that Mini Panels when sometimes used with the block system (for components sometimes needed outside of Panels) will work with optional context.
#2508433: Blocks dont support recent addition of "optional" checkbox to require contexts within mini panels
Comment #29
misthero CreditAttribution: misthero commentedpatch 10 works here coupled with https://www.drupal.org/node/2405187#comment-9499937
Comment #30
scottalan CreditAttribution: scottalan at Phase2 commentedhttps://www.drupal.org/node/1588212#comment-8801845 patch for panels (panels-1588212-10.patch) worked for me as well. Would be great to get this in!
Comment #31
mpotter CreditAttribution: mpotter commentedSo, #10 was already commited to Panels. And to answer #27, Ctools 1.9 includes the needed patch. So I think this is Fixed and not "Needs Work"