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.
Sorry if this is a duplicate, but I couldn't find an issue for it. I'm trying to add a page title block to a panels display that has the page title configured directly through the Panels UI. If I use a block outside of the panels layout, it displays fine, but when I place the page title block inside the panels display, nothing shows up. Looking a little deeper, it appears there's a matching issue for the block page variant #2626090: Page title block placed on block page renders empty, but I can't find anything for Panels.
Comment | File | Size | Author |
---|---|---|---|
#42 | panels--page-title_does_not_display_8.4.x.patch | 8.23 KB | yeaha |
| |||
#27 | panels--page_title_does_not_display--2869412-27.patch | 8.1 KB | Alumei |
Comments
Comment #2
rbayliss CreditAttribution: rbayliss at Last Call Media commentedHere's an attempt at a fix. I'm looking for some feedback on the approach, although I'm aware it will need tests. Is it kosher to expose the renderPageTitle() method on the PanelsDisplayVariant? If so, should renderPageTitle() have some logic to automatically call getPageTitle()?
Comment #3
rbayliss CreditAttribution: rbayliss at Last Call Media commentedComment #5
sylus CreditAttribution: sylus commentedThis got the title to work for me as well, and is very similar to the approach leveraged in the corresponding patch. ^_^
The only thing I noticed is that when page_title_block is leveraged is should take over the title handling functionality from the DisplayVariant. Right now I get both the title from the Display and the new added page_title_block.
Thanks so much for pushing this forward!
Comment #6
arosboro CreditAttribution: arosboro at DropForge Labs commentedThis patch is working well, I did notice that if show title is checked on the title block it shows the actual page title (twice), not the manually configured title in the block settings.
Comment #7
moymilo CreditAttribution: moymilo as a volunteer and at Drupal Ukraine Community commentedComment #8
dstorozhukComment #9
piggito CreditAttribution: piggito as a volunteer and at Skilld commentedAdding a reroll for the patch in #2
The patch works but we still need to fix the tests to consider the new call to
getPageTitle()
Comment #10
andypostComment #12
piggito CreditAttribution: piggito as a volunteer and at Skilld commentedFixing
Drupal\Tests\panels\Unit\StandardDisplayBuilderTest
Comment #13
andypostQueued for php71 as well
btw `string` type will not work in PHP 5.5.9 as minimal supported by core
Comment #15
andres.torres CreditAttribution: andres.torres commentedConfirmed, same behavior when trying to add the Page Title block using Panelizer, title won't display.
Running the patch #12 throws the following msgs:
patching file src/Plugin/DisplayBuilder/StandardDisplayBuilder.php
Hunk #1 FAILED at 3.
Hunk #2 succeeded at 83 (offset -12 lines).
Hunk #3 succeeded at 107 (offset -12 lines).
Hunk #4 succeeded at 163 (offset -14 lines).
1 out of 4 hunks FAILED -- saving rejects to file src/Plugin/DisplayBuilder/StandardDisplayBuilder.php.rej
patching file tests/src/Unit/StandardDisplayBuilderTest.php
Hunk #1 succeeded at 66 (offset -3 lines).
and the title starts showing up as [node:title] instead of rendering the title string.
Comment #16
Alumei CreditAttribution: Alumei commentedRemoved the 'string' typehint from the method signature as pointed out in #13.
Comment #17
Alumei CreditAttribution: Alumei commentedI got the same problem as @andres.torres described in #15 with token replacement. This is due to the fact that the patch only uses the RAW value for the title block instead of the "rendered" one.
So this patch resolves that by exposing the "rendered" title on the
PanelsDisplayVariant
.Comment #18
Alumei CreditAttribution: Alumei commentedMissed the test, fixed now.
Comment #21
Alumei CreditAttribution: Alumei commentedRetesting the latest patch from #18
Comment #22
Alumei CreditAttribution: Alumei commentedIs there any way to push this forward as this issue affects PE #2933423: Content of placed title block does not show up.
Is there something still missing? Given some pointers I would be happy to improve the patch if necessary.
Comment #23
andypostLooks good, except not all broken places covered with tests
Comment #24
Alumei CreditAttribution: Alumei commentedI tried building a test that verifies that a the title is build correctly & that a token is evaluated correctly as well.
As the later part requires working token behavior I tried to implement it as a Kernel test.
But I keep running into the problem:
I get to that point as soon as I try to construct a PageVariant with a title-block configured.
I attached 2 to showcases this, does somebody have a solution?
Comment #27
Alumei CreditAttribution: Alumei commentedI got a test working, that verifies that that the problem is being solved.
Comment #28
Alumei CreditAttribution: Alumei commentedComment #30
andypostThat looks great!
Looking at fix I wondered why
getRenderedPageTitle()
added? It looks like just wrapper that not neededAlso issue summary needs update
Comment #31
Alumei CreditAttribution: Alumei commentedgetRenderedPageTitle()
is used at two paces:Drupal\panels\Plugin\DisplayVariant\PanelsDisplayVariant:build()
=> Were it is used to set '#title' for the pageDrupal\panels\Plugin\DisplayBuilder\StandardDisplayBuilder:buildRegions()
=> Were previous patches added the code to set the title for the title blockAs both places needed a
renderPageTitle()
&getPageTitle()
call I found it seemed like the most straight forward solution to addgetRenderedPageTitle()
that combines both and does not requirerenderPageTitle()
to be changed from protected to public.Comment #32
toddwoof CreditAttribution: toddwoof commentedMaybe I have a different issue, but the node title does not display for me _unless_ I place it in a block. So if I add [node:title] or anything else to "Page title," it is not rendered. I can add a block to the layout with the page title, but then there's no control over the markup.
Anyone else seeing this? Tried the patch in #27; no change. Brand new site, just starting to set up (8.5.3, nothing unusual).
Comment #33
toddwoof CreditAttribution: toddwoof commentedOkay, maybe my issue is more similar than I had thought. My use case is Adaptive Theme and Drupal 8.5.3, brand new site. (But I tested in Seven also.)
I started adding page title blocks in the block layout, and discovered that I can get the page title to display for panelized content types if three things are present: (1) there is a page title block in the block settings in the Main content area, and (2) there is another page title block in the block settings outside the Main content area (such as Content prefix), and (3) I have the content type panelized and [node:title] entered in the Page title field.
The two blocks in the blocks layout don't need to have any content types checked, but they both have to be there. Remove either one, and the node title vanishes.
So: Am I misunderstanding how this is supposed to work? Seems to me that just #3 should be needed.
Comment #34
Alumei CreditAttribution: Alumei commented@toodwoof - From what I gathered when working on the patches it seemed as follows:
If a panel is displayed as the main-content on a page the configured panels title is set for the page title rendering.
If one now only places a page title block outside of panes on the page via the block configuration page, that block should use the title intended for page title rendering. In that case it would be the panes title.
If one now only places a page title block inside of the panel, without a patch of this issue, that block would remain empty. This issue is trying to solve that use-case, by passing along the relevant page title information to the placed page-title block.
I would expect that your (3) is the most relevant as it ensures that the correct title is displayed. As for the rest I would actually expect that either (1) or (2) would suffice to get the panels title to show as page title, so long as the latest patch is applied ... strange!
Comment #36
Alumei CreditAttribution: Alumei commented@toodwoof
Where you ever able to get this working?
I just tried replicating you issue on a fresh site using simplytest.me.
I can not replicate it using the following steps:
Comment #37
Alumei CreditAttribution: Alumei commentedSorry, accidentally tested against the wrong branch. retested be sure. As such back to needs review.
Comment #38
toddwoof CreditAttribution: toddwoof commented@alumei I need to test on a fresh install. For the site I was working on, I abandoned Panels and moved to the formative core layout function. Will take a test drive in another environment when I can!
Comment #39
NWOM CreditAttribution: NWOM commented#27 doesn't seem to work for me quite right. Rather than showing no title (before the patch), it instead shows the following raw html as a title:
<span data-quickedit-field-id="node/10/title/und/full">TITLE</span>
Comment #40
Idas CreditAttribution: Idas commentedAre there any news about it?
Comment #41
rutiolmaThe patch at #27 seems to work well for me.
@toddwoof, I always had to place the Page Title block in order to display the title, so maybe this is by design? It doesn't seem related with this issue and another issue should be created for this IMO.
@NWOM it seems you're using quickedit. I enabled it on my site and it doesn't cause any issue so it would be nice to get more info about that issue. Maybe theming issue?
Comment #42
yeaha CreditAttribution: yeaha commentedadjusted patch line nrs of the patch in comment #27 on branch 8.4.x
Comment #43
yeaha CreditAttribution: yeaha commentedback visible
Comment #44
yeaha CreditAttribution: yeaha commentedComment #46
japerryDid my own testing, and this seems to work for me too. Fixed!