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

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

bart.hanssens’s picture

Same issue here. Backtrace from devel module

10: ctools_context_token_convert() (Array, 2 elements)
  file (String, 67 characters ) 
    profiles/ferry/modules/contrib/ctools/plugins/contexts/token.inc:54
  args (Array, 3 elements)
    0 (Object) ctools_context
    1 (String, 12 characters ) current-date
    2 (Array, 0 elements)
 9: ctools_context_convert_context() (Array, 2 elements)
  file (String, 62 characters )
    profiles/ferry/modules/contrib/ctools/includes/context.inc:521
  args (Array, 3 elements)
    0 (Object) ctools_context
    1 (String, 12 characters ) current-date
    2 (Array, 0 elements)
 8: ctools_context_keyword_substitute() (Array, 2 elements)
  file (String, 62 characters )
    profiles/ferry/modules/contrib/ctools/includes/context.inc:669
  args (Array, 3 elements)
    0 (String, 32 characters ) Panel %token:current-date:custom
    1 (Array, 0 elements)
    2 (Array, 1 element)
bart.hanssens’s picture

Quick 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

bart.hanssens’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, ctools-token_in_panel-1770670-2.diff, failed testing.

bart.hanssens’s picture

Status: Needs work » Needs review
FileSize
642 bytes

Patch with unix line-endings

christoph’s picture

This patch worked for me. Thanks.

Dig1’s picture

Great 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

areynolds’s picture

I 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!

goodeit’s picture

Status: Needs review » Closed (duplicate)

This 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.

elly’s picture

Thank you, this patch worked for me against latest ctools dev.

renegaed’s picture

Status: Needs work » Closed (duplicate)

the 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.

renegaed’s picture

Priority: Normal » Major
Status: Closed (duplicate) » Needs work
moonray’s picture

Status: Closed (duplicate) » Needs work

This is still an issue with %token:current-page:url .
The patch in #5 fixed the notice and the token.

Summit’s picture

Version: 7.x-1.2 » 7.x-1.x-dev
Status: Needs work » Reviewed & tested by the community

Hi, shouldn't this than be RTBC?
Greetings, Martijn

podarok’s picture

Status: Reviewed & tested by the community » Needs work

#14 nope, due to #11

pirog’s picture

This seems to be in 1.3 already...

JayShoe’s picture

Hello,

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