The Page Title Ctools plugin provides a panel pane wrapper for drupal_get_title() with an option to choose the wrapper tag to use: None, H1, H2, etc.

If you use this pane in a panel page (e.g. we use it in Panels Everywhere site template) with no wrapper, and the page title is empty (e.g. from a Panel Title set to [No Title]), then the pane is not shown.

However, if you specify a wrapper tag, and the page title is empty, then the pane is shown with an empty tag, such as <h1></h1>.

In the patch to follow, the pane will produce no output at all, when the page has no title at all, regardless of whether a wrapper tag is used or not.

Comments

jwilson3’s picture

Title: Empty page title produces non-empty page_title pane when wrappers are used » Empty page title produces non-empty page_title pane when wrapper is uses
Status: Active » Needs review
StatusFileSize
new972 bytes
jwilson3’s picture

Title: Empty page title produces non-empty page_title pane when wrapper is uses » Hide empty page title pane when wrapper tag is used
ACF’s picture

I had the same problem, but came up with a slightly different fix, as I don't see any reason to create the token if the title isn't set.

jwilson3’s picture

I don't know enough about panels to know which of these two solutions is better. The main question for me is will $panel_args[0] always be present, and be an object? Patch in #1 seems "safer" just because it uses drupal_get_title() instead of digging into passed variables.

jwilson3’s picture

StatusFileSize
new571 bytes

The patch in #1 was not generating the wrapper tag, but was still generating a token of the form <!-- ctools-page-title-839b479e895e2bc96ecac092c6aa6636 --> (as mentioned in #3), which was causing the pane to be printed on the page, even though it is technically empty and shouldn't be there.

So in this patch I've adapted #3 to use drupal_get_title() which is safer than depending on the panel argument and is consistent with how ctools_page_title_content_type_token() creates the HTML for the pane, when a title does exist.

@ACF: would you be willing to test and RTBC this, to push it along?

antonyanimator’s picture

#5 patched worked for me

mglaman’s picture

Status: Needs review » Reviewed & tested by the community

#5 looks good, applies, does the job. Dig the logic behind it.

damienmckenna’s picture

  • japerry committed 8fc065c on 7.x-1.x authored by jwilson3
    Issue #2265451 by jwilson3, ACF: Hide empty page title pane when wrapper...
larowlan’s picture

This seems to break page_manager titles.

the check to drupal_get_title() is too early, page manager calls drupal_set_title *after* this check has run.

sylus’s picture

Yup my CI build flagged an error when creating a new draft and checking for the existence of the title on the new page save. The title was not present at all.

Really glad this was reported and have confirmation, this might effect a few people.

sylus’s picture

StatusFileSize
new571 bytes

Just providing a patch to revert this commit for drush make purposes on top of latest stable (1.9)

damienmckenna’s picture

Moving this to the v7.x-1.10 release plan.

damienmckenna’s picture

Ugh. Back to the drawing board for v7.x-1.10.

sylus’s picture

Apologies, looks like I was wrong and the ultimate culprit (at least for me) was #2437773: Attached CSS and JS files are not loaded where they changed logic to do with the node_view.inc.

https://www.drupal.org/node/2437773#comment-10240035

Reverting one commit before resolved my issue.

jwilson3’s picture

Hrm, so did the commit here really break something, or is it actually something else?

larowlan’s picture

Yep, I'll write a test

rahul.shinde’s picture

Status: Reviewed & tested by the community » Needs work

@jwilson3 @sylus, #5 holding page title to render while #13 resolves this. cause

if (!drupal_get_title()) {
    return;
  }

wont have any title to show because it got called before drupal_set_title

larowlan’s picture

StatusFileSize
new571 bytes

Patch that reverts for those using a make file etc

pontus_nilsson’s picture

I also stumbled upon this issue where my page titles from ctools content types was used for title and no longer showed. Using patch in #20 until new release is out.

sjancich’s picture

I can confirm this is an issue when creating custom Panels pages.

FrankH’s picture

There is a further issue with this commit in the case where a title override is specified for a page that has no menu item. In such a case, the call to drupal_get_title() returns NULL because the page title has not yet been set (#11) and no menu item exists.

This slight modification will cause the function to return without setting a title as intended by the original commit -- except when a title override is specified.

if (!drupal_get_title() && $conf['override_title'] != 1) {
    return;
} 
jwilson3’s picture

It would be super helpful if someone could provide a very basic panel export that demonstrates this problem. I've tried to replicate it myself on a clean install with nothing but ctools, page manager and panels, using a node variant panel but cannot.

FrankH’s picture

StatusFileSize
new2.36 KB

See attached. It creates a page "/test" that demonstrates the problem. If you view the page using CTools 7.x-1.9, the title will not be displayed. Add a menu item pointing to /test and the title will be displayed (because drupal_get_title() will return TRUE). Remove the menu item and the title will not be displayed. Remove these lines:

if (!drupal_get_title()) {
    return;
}

from ctools/modules/plugins/content_types/page/page_title.inc (line 32) and the title will be displayed whether the menu item is present or not. Changing the lines to

if (!drupal_get_title() && $conf['override_title'] != 1) {
    return;
  }

allows the drupal_get_title() test to remain in place while taking into account the possibility of a title override being specified.

mvc’s picture

Status: Needs work » Reviewed & tested by the community

Patch in #23 works for me. I had a panel which contained only a custom text pane and a title pane, and the title pane didn't render without this change.

japerry’s picture

Status: Reviewed & tested by the community » Needs work

Patch 23 looks pretty good to me, with an exception of this:

+++ b/plugins/content_types/page/page_title.inc
@@ -29,7 +29,7 @@ $plugin = array(
+  if (!drupal_get_title() && $conf['override_title'] != 1) {

While the example plugin modules show override_title to be 0 or 1, the rest of the ctools code has this as a boolean. Lets stay consistent with the rest of the module plugins.

/me makes note to update example plugin code....

damienmckenna’s picture

This didn't get added to 7.x-1.10.

jenlampton’s picture

Status: Needs work » Needs review
StatusFileSize
new574 bytes

Confirming the patch in #23 solves the problem. Attached patch changes 1 to TRUE as requested.

mvc’s picture

Status: Needs review » Reviewed & tested by the community

Still works for me. Thanks!

roland.molnar’s picture

Status: Reviewed & tested by the community » Needs work

I can confirm that this still cause issue with Panels pages (as described in #11).
Patch #29 and #23 does not solve the problem.

jibran’s picture

Status: Needs work » Needs review
StatusFileSize
new756 bytes
new721 bytes

Here is an updated patch with proper fix.

larowlan’s picture

Status: Needs review » Reviewed & tested by the community
rivimey’s picture

Issue tags: ++Needs_tests

jibran, the the patch in #32 does a drupal_get_title() in the same place as the patch that roland.molnar indicated fails with Panels pages, presumably because drupal_set_title() hasn't been called yet (as in #11).

Can you confirm whether you have tested the fix in #32 with the scenario mentioned in #11?

rivimey’s picture

Issue tags: -+Needs_tests +Needs_tests
rivimey’s picture

Status: Reviewed & tested by the community » Needs work
jibran’s picture

Status: Needs work » Needs review
Issue tags: -Needs_tests +Needs tests

@rivimey drupal_set_title() is called in drupal_get_title() so calling it in the sampe place is alright. I added the second condtion to the statement $conf['override_title'] === PANELS_TITLE_NONE which means if title is not set and page is configured not to show the title then bailout. WIth the addition of $conf['override_title'] === PANELS_TITLE_NONE we made sure that doesn't matter title is set or not if page is configured to show the title then go ahead and set the title.

I tested the exact scenario mentioned in #11. I was updating the same site on which @larowlan encountered the problem. @larowlan RTBCed it cause he tested that fix and tests are passing on a client's project.

I'm not sure how to write tests about it in ctools but I can confirm that I had some Behat test failing on client's project because the fix was not right and they are passing now after the patch.

rivimey’s picture

@jibran, many thanks for your explanation earlier, which was helpful.

i thought the problem with drupal_set_title() was not that it was not called but that it wasn't called with the correct title string : as I am sure you realize, drupal_set_title() just stores a string provided statically (ugh!). It would be good if @larowlan could confirm?

I am slightly wary about the new constants. As the names suggest, the PANELS_TITLE_NONE et al are defined in panels.module. I have checked and a ctools installation with panels not present doesn't crash and burn always, but because it's all about plugins and config it is very possible I haven't done the right thing to invoke it. Is there anything that prevents this file being read by php unless panels.module has already been loaded?

[Note: ordinarily I would be very happy to see named constants replacing magic numbers, but aversion to breaking things is even higher priority :-) ]

jibran’s picture

Status: Needs review » Needs work

It would be good if @larowlan could confirm?

I'll ping him.

As the names suggest, the PANELS_TITLE_NONE et al are defined in panels.module.

Good catch I'll fix this up.

larowlan’s picture

I can't remember...this issue has been around so long. I'll chat with Jibran about it in person this week.

rivimey’s picture

@larowlan, @jibran many thanks.

jibran’s picture

Status: Needs work » Needs review
StatusFileSize
new755 bytes
new687 bytes

Here is a new patch.

jibran’s picture

StatusFileSize
new638 bytes
new736 bytes

Fixed a doc issue.

larowlan’s picture

Status: Needs review » Reviewed & tested by the community

Yeah, from comment #11, it wasn't that the wrong title was used, it was

the check to drupal_get_title() is too early, page manager calls drupal_set_title *after* this check has run.

So the patch at #43 is good in my book.

We should create a follow up for moving those panels constants into ctools and deprecating the panels ones.

rivimey’s picture

I think some additional +1s for the latest patch would be good to see, but as far as I can tell this is looking good.

@larowlan would you be able to create the new Issue for

moving those panels constants into ctools and deprecating the panels ones.

although I suspect it won't be quite that simple :)

jenlampton’s picture

I think some additional +1s for the latest patch would be good to see

The patch in #43 is working for me, thanks! :) +1

sylus’s picture

The patch in #43 is working great for me as well. Thanks for all the hard work everyone!

japerry’s picture

Status: Reviewed & tested by the community » Needs work

This looks okay to me in theory, but lets add an isset or empty around the override_title key just in case.

damienmckenna’s picture

This wasn't finished in time so hopefully it'll be finished in time for 1.13.

jenlampton’s picture

Status: Needs work » Needs review
StatusFileSize
new755 bytes

Very well, this patch adds an isset().

rivimey’s picture

Status: Needs review » Reviewed & tested by the community

Looks fine to me. :-) Thanks Jen.

  • japerry committed 89fbdf8 on 7.x-1.x
    Issue #2265451 by jibran, jwilson3, jenlampton, FrankH, larowlan, sylus...
japerry’s picture

Status: Reviewed & tested by the community » Fixed

Merged in #43. Thanks!

Status: Fixed » Closed (fixed)

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