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.
| Comment | File | Size | Author |
|---|---|---|---|
| #50 | ctools-hide_empty_page_title-2265451-50.patch | 755 bytes | jenlampton |
| #43 | hide_empty_page_title-2265451-43.patch | 736 bytes | jibran |
Comments
Comment #1
jwilson3Comment #2
jwilson3Comment #3
ACF commentedI 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.
Comment #4
jwilson3I 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 usesdrupal_get_title()instead of digging into passed variables.Comment #5
jwilson3The 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?
Comment #7
antonyanimator commented#5 patched worked for me
Comment #8
mglaman#5 looks good, applies, does the job. Dig the logic behind it.
Comment #9
damienmckennaComment #11
larowlanThis 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.
Comment #12
sylus commentedYup 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.
Comment #13
sylus commentedJust providing a patch to revert this commit for drush make purposes on top of latest stable (1.9)
Comment #14
damienmckennaMoving this to the v7.x-1.10 release plan.
Comment #15
damienmckennaUgh. Back to the drawing board for v7.x-1.10.
Comment #16
sylus commentedApologies, 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.
Comment #17
jwilson3Hrm, so did the commit here really break something, or is it actually something else?
Comment #18
larowlanYep, I'll write a test
Comment #19
rahul.shinde@jwilson3 @sylus, #5 holding page title to render while #13 resolves this. cause
wont have any title to show because it got called before
drupal_set_titleComment #20
larowlanPatch that reverts for those using a make file etc
Comment #21
pontus_nilssonI 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.
Comment #22
sjancich commentedI can confirm this is an issue when creating custom Panels pages.
Comment #23
FrankH commentedThere 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.
Comment #24
jwilson3It 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.
Comment #25
FrankH commentedSee 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:
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
allows the drupal_get_title() test to remain in place while taking into account the possibility of a title override being specified.
Comment #26
mvcPatch 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.
Comment #27
japerryPatch 23 looks pretty good to me, with an exception of this:
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....
Comment #28
damienmckennaThis didn't get added to 7.x-1.10.
Comment #29
jenlamptonConfirming the patch in #23 solves the problem. Attached patch changes 1 to TRUE as requested.
Comment #30
mvcStill works for me. Thanks!
Comment #31
roland.molnar commentedI can confirm that this still cause issue with Panels pages (as described in #11).
Patch #29 and #23 does not solve the problem.
Comment #32
jibranHere is an updated patch with proper fix.
Comment #33
larowlanComment #34
rivimeyjibran, 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?
Comment #35
rivimeyComment #36
rivimeyComment #37
jibran@rivimey
drupal_set_title()is called indrupal_get_title()so calling it in the sampe place is alright. I added the second condtion to the statement$conf['override_title'] === PANELS_TITLE_NONEwhich 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_NONEwe 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.
Comment #38
rivimey@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.modulehas 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 :-) ]
Comment #39
jibranI'll ping him.
Good catch I'll fix this up.
Comment #40
larowlanI can't remember...this issue has been around so long. I'll chat with Jibran about it in person this week.
Comment #41
rivimey@larowlan, @jibran many thanks.
Comment #42
jibranHere is a new patch.
Comment #43
jibranFixed a doc issue.
Comment #44
larowlanYeah, from comment #11, it wasn't that the wrong title was used, it was
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.
Comment #45
rivimeyI 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
although I suspect it won't be quite that simple :)
Comment #46
jenlamptonThe patch in #43 is working for me, thanks! :) +1
Comment #47
sylus commentedThe patch in #43 is working great for me as well. Thanks for all the hard work everyone!
Comment #48
japerryThis looks okay to me in theory, but lets add an isset or empty around the override_title key just in case.
Comment #49
damienmckennaThis wasn't finished in time so hopefully it'll be finished in time for 1.13.
Comment #50
jenlamptonVery well, this patch adds an isset().
Comment #51
rivimeyLooks fine to me. :-) Thanks Jen.
Comment #53
japerryMerged in #43. Thanks!