I am updating a site that used panels 6.x-2.0-alpha3 to panels 6.x-3.10, the latest 6.x version. (After this update, we will be upgrading to Drupal7.) When I installed 6.x-3.10, many of the existing panel pages content disappeared. I attributed this to the 2.0 to 3.10 upgrade and I am rebuilding the many panel pages.

One feature of these panel pages is that there is a node at the bottom of the panel which contains the following code:
<a href="/forms/contact-us?pg=<?php print drupal_get_title(); ?>"...
In 2.0-alpha3, in the Settings Pane, there is a field Page Title which contains the page title desired for this panel page. This title is picked up by drupal_get_title and sent to the form.

However, I can't get this to work in Panels 3.10. It seems that the Page Title field has moved to the Content Pane. I populated the Title field and have a Title Type of Manually Set. This title appears at the top of the panel page. But the node that includes the code shown above seems to return blank rather than the title.

How can I get the title populated in Panels 6.x-3.10 so that drupal_get_title will pick it up?

Comments

merlinofchaos’s picture

Status: Active » Fixed

With the Page Manager system, I think the page title is probably being set after rendering. CTools has a mechanism to get past this, using a token replacement system. If you look in ctools/plugins/content_types/page/page_title.inc which is the plugin that renders the page title, it uses this system.

Its usage is a little more complex than you actually need (which is fortunate, because it's a little tough to tell what's actually going on there.

All you actually need is this:

  $title = ctools_set_variable_token('title');

At the time you render it, the token will be an HTML comment. During page processing, that HTML comment will be replaced with the page title; something that is important since at the time of rendering, sometimes you just can't know data like the page title. You can use the above for any variable that's available in hook_preprocess_page().

Status: Fixed » Closed (fixed)

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

azinck’s picture

Merlin's advice isn't working for me in recent D7 versions of Panels and ctools. See here for details: #1964874: $variables not injected properly into ctools_page_token_processing()