Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi,
Using latest Ctools 1.2, Panels 3.3 and Token 1.2 I got problems when adding Token Context to a Panel.
Every Token I try to use gives this notice:
Notice: Undefined offset: 1 in ctools_context_token_convert() (regel 53 van /httpdocs/sites/all/modules/ctools/plugins/contexts/token.inc).
I tried to add random a Token, but all adding to a panel gives the error.
%token:default-domain:name
%token:current-page:title
Thanks a lot in advance for going into this!
Greetings, Martijn
Comment | File | Size | Author |
---|---|---|---|
#5 | ctools-token_in_panel-1770670-4.diff | 642 bytes | bart.hanssens |
#2 | ctools-token_in_panel-1770670-2.diff | 655 bytes | bart.hanssens |
Comments
Comment #1
bart.hanssens CreditAttribution: bart.hanssens commentedSame issue here. Backtrace from devel module
Comment #2
bart.hanssens CreditAttribution: bart.hanssens commentedQuick and dirty patch, may break other stuff...
It appears that the preg_match_all in ctools_context_keyword_substitute() only matches the first part of the token (e.g. current-date instead of current-date:long)
Tested it with %token:current-date:long as title
Comment #3
bart.hanssens CreditAttribution: bart.hanssens commentedComment #5
bart.hanssens CreditAttribution: bart.hanssens commentedPatch with unix line-endings
Comment #6
christoph CreditAttribution: christoph commentedThis patch worked for me. Thanks.
Comment #7
Dig1 CreditAttribution: Dig1 commentedGreat job.
I updated to: Drupal core 7.15, Calendar 7.x-3.4+0-dev (2012-May-20), Chaos tool suite (ctools) 7.x-1.2+3-dev (2012-Sep-19), Date 7.x-2.6, Entity API 7.x-1.0-rc3+10-dev (2012-Sep-07), Panels 7.x-3.3+1-dev (2012-Sep-07) and straight away I was getting multiple errors stating:
Notice: Undefined offset: 1 in ctools_context_token_convert() (line 53 of .../sites/all/modules/ctools/plugins/contexts/token.inc).
specficially this applied when I used %token:current-date:calendar and %token:site:name as substitutions.
- I downloaded this patch to the directory...sites/all/modules/ctools/includes
- Issued the command 'patch < ctools-token_in_panel-1770670-4.diff'
- the response was 'patching file context.inc'
and then the errors disappeared from my site.
Success and thank you bart.hanssens
Comment #8
areynolds CreditAttribution: areynolds commentedI didn't experience the "Undefined offset" described in the original issue, but I was experiencing token replacement issues using date tokens combined with formaters (%node:created:short, for example) in 7.x-1.x-dev and this patch has fixed them. Thanks!
Comment #9
goodeit CreditAttribution: goodeit commentedThis is a duplicate of https://drupal.org/node/1727804.
The patch at https://drupal.org/node/1727804#comment-6395400 is the same as #5 here and includes a test case to prevent a regression.
Comment #10
elly CreditAttribution: elly commentedThank you, this patch worked for me against latest ctools dev.
Comment #11
renegaed CreditAttribution: renegaed commentedthe patch worked for me however token replacement is not working for the following types of patterns that exclude the % sign:
<a href="[token:site:url]login">Login</a>
the token is not being replaced in panel panes custom content block. Any help would be greatly appreciated. Thank you.
Comment #12
renegaed CreditAttribution: renegaed commentedComment #13
moonray CreditAttribution: moonray commentedThis is still an issue with
%token:current-page:url
.The patch in #5 fixed the notice and the token.
Comment #14
Summit CreditAttribution: Summit commentedHi, shouldn't this than be RTBC?
Greetings, Martijn
Comment #15
podarok#14 nope, due to #11
Comment #16
pirog CreditAttribution: pirog commentedThis seems to be in 1.3 already...
Comment #17
JayShoe CreditAttribution: JayShoe commentedHello,
I'm having a similar problem with Panels and Tokens. I stumbled upon this thread. Can someone please tell me if this is resolved? That is - are custom tokens supposed to work on panels?
Here is my issue #2151127: Entity Tokens do not display when rendered via Content Pane in Panels