It would be great if CTools would allow you to create a custom string context in the UI. The current implementation has a "no ui" value set, but why can't we allow that to be set? There are a number of neat use cases you might want to add a custom context.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

populist’s picture

Status: Active » Needs review
FileSize
782 bytes

Here is a patch that changes the module!

merlinofchaos’s picture

Status: Needs review » Fixed

Huh. I have no idea why string contexts were never allowed in the UI. Maybe just in the early evolution of the system they didn't seem at all useful.

populist’s picture

The use case that I found this most helpful was when I wanted to restrict certain content types to certain panel pages. This was really helpful in the context of making "administration" Panels because each panel page could be given a string context (i.e. "panopoly_admin") and then each content type that corresponds to administration can require that context. This is cool because then the admin content types *only* show up on admin panel pages since they require said context.

merlinofchaos’s picture

Hmm. I'm not sure string contexts are really what you want, there. You can't require specific strings for the content to show up, only that a string context exists.

I think you actually want specific types of contexts that correlate exactly to specific types of contexts.

So a "panopoly admin" context which can then be added to pages to say "Hey this is a panopoly admin page" and the like. A built in page task could then provide the basic panopoly admin page with that context baked in pretty easily.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

geek-merlin’s picture

Status: Closed (fixed) » Needs review
FileSize
1.73 KB

It seems the committed patch allows defining a string context but the value can not be set there which makes this useless for site builders in panels ui.

This patch fixes it.

(Note: we might want to do the same for token.)

Angry Dan’s picture

FileSize
531 bytes
1.49 KB

#6 thanks for this patch it solved a problem for me - I needed to be able to pass a string from a panel to a mini panel and then on to a view. The only way to do this is via a string context on the base panel because mini panels (unlike views) doesn't allow you to input contexts as strings.

There is a small bug introduced in the patch, if you add a string argument to your panel then you'll get all kinds of trouble because of the check on $data['string'] where the bit of ctools that converts an argument into a context passes $data as a raw string.

See attached patch for a fix which keeps things backwards compatible.

mohamadaliakbari’s picture

Thanks. This patch was useful when I tried to pass "all" string to views to bypass some arguments.

geek-merlin’s picture

Category: Feature request » Bug report
Issue summary: View changes
Status: Needs review » Reviewed & tested by the community

The last patch applies cleanly and fixes the issue.
Reclassifying as bug.

das-peter’s picture

+1 from me. Looks clean and works as expected - thanks :)

  • Commit e3344a6 on 7.x-1.x by japerry:
    Issue #1774434 by axel.rutz, Angry Dan: Allow string context to be...
japerry’s picture

Status: Reviewed & tested by the community » Fixed

Looks good to me as well! Committed.

geek-merlin’s picture

Status: Fixed » Needs work

I've already worked a while with this patch now and i think it needs an improvement, to use placeholder tokens.
We should provide that in a followup.

  • merlinofchaos committed e7b85db on 8.x-2.x authored by populist
    Issue #1774434 by populist: Added Allow String Context to Be Created in...
  • japerry committed e3344a6 on 8.x-2.x
    Issue #1774434 by axel.rutz, Angry Dan: Allow string context to be...
sylus’s picture

This commit has resulted in the following error once updating past CTools 1.4.

Notice: Undefined index: string in ctools_context_create_string() (line 50 of /xxx/profiles/openatrium/modules/contrib/ctools/plugins/contexts/string.inc).

It was reported over here at: #2424017: Malformed (and useless) string context causes errors with new versions of CTools

sylus’s picture

I have taken das-peter's suggestion to fix this and attaching as a patch. Let me know if this should go into its own issue.

das-peter’s picture

Status: Needs work » Needs review

@sylus Thanks for the patch. May I ask you to check the panopoly code too? As implied in #2424017: Malformed (and useless) string context causes errors with new versions of CTools it looks like something is creating a string context in a what that doesn't make to much sense. So before we fix the error message we might want to ensure that the context is properly created and we don't hide an underlying issue.

Setting to needs review - but not RTBC as I basically suggested that code ;)

B-Prod’s picture

@das-peter: the reported bug related to Panopoly is not caused by the changes discussed here, but to a wrong string context defined in Panopoly Admin default pages. So this should be fixed in Panopoly and do not interfere with current issue.

  • merlinofchaos committed e7b85db on 8.x-3.x authored by populist
    Issue #1774434 by populist: Added Allow String Context to Be Created in...
  • japerry committed e3344a6 on 8.x-3.x
    Issue #1774434 by axel.rutz, Angry Dan: Allow string context to be...
geek-merlin’s picture

Status: Needs review » Closed (won't fix)

like stated in #17 and #18: we should not silently hide malformed data input.