Not sure how well this will play into the refactoring around displays, but it seems to be an important feature to be able to control this, the page label is usually not what you want ;)

Patch is just a proof of concept, but does come with token integration as that was pretty easy and allowed me to do what I had to. Can be replaced with directly using context data, but there's no UI/API yet for that..

Comments

berdir’s picture

Status: Active » Needs review
StatusFileSize
new2.77 KB

And here's the patch.

Status: Needs review » Needs work

The last submitted patch, 1: page-title-2287733-1.patch, failed testing.

tim.plunkett’s picture

+++ b/src/Plugin/PageVariantBase.php
@@ -324,4 +341,26 @@ abstract class PageVariantBase extends PluginBase implements PageVariantInterfac
+        if ($token_type == 'taxonomy_term') {
+          $token_type = 'term';
+        }

Ugghhhhhhhhh

Otherwise, looks cool.

berdir’s picture

berdir’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
StatusFileSize
new5.45 KB

Ok, extended the node selection test to set the page title as well including token replacement support.

Moved the configuration down to the block display variant, doesn't make sense to have that in the http status response variant...

interdiff would be bigger than the patch due to moving/changing almost all of the previous code.

Status: Needs review » Needs work

The last submitted patch, 5: page-title-2287733-5.patch, failed testing.

berdir’s picture

Status: Needs work » Needs review
StatusFileSize
new5.51 KB
new834 bytes

ah, page_title is now only displayed when editing them. so making the submit conditional too.

Status: Needs review » Needs work

The last submitted patch, 7: page-title-2287733-7.patch, failed testing.

berdir’s picture

Status: Needs work » Needs review
StatusFileSize
new6.04 KB
new536 bytes

I thought I added that...

tim.plunkett’s picture

  1. +++ b/src/Plugin/DisplayVariant/BlockDisplayVariant.php
    @@ -306,6 +333,10 @@ class BlockDisplayVariant extends VariantBase implements ContainerFactoryPluginI
    +    if (!empty($form_state['values']['page_title'])) {
    

    Wouldn't this prevent an existing title from being replaced by an empty string?

  2. +++ b/src/Plugin/VariantBase.php
    @@ -326,6 +326,40 @@ abstract class VariantBase extends PluginBase implements VariantInterface {
    +        if ($token_type == 'taxonomy_term') {
    +          $token_type = 'term';
    +        }
    

    Let's put an explicit @todo here

  3. +++ b/src/Tests/PageNodeSelectionTest.php
    @@ -96,7 +99,14 @@ class PageNodeSelectionTest extends WebTestBase {
         $this->assertNoText('Node View');
    

    This shouldn't care about 'Node View' now

berdir’s picture

Ok, implemented as discussed, always display the page title and default to the page label when adding a new display. Had to init the display to make that work and have access to the page.

Also updated the tests accordingly.

berdir’s picture

Grrr, take-newest-patch-from-current-directory-without-thinking-fail.

The last submitted patch, 11: 1920688-token-replace-multiple-instances-same-type-21.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 12: page-title-2287733-11.patch, failed testing.

berdir’s picture

Fixing unit tests.

berdir’s picture

Status: Needs work » Needs review
berdir’s picture

StatusFileSize
new11.86 KB

Re-rolled.

tim.plunkett’s picture

StatusFileSize
new8.12 KB
new2.62 KB

The deriver issue went in.

Status: Needs review » Needs work

The last submitted patch, 18: pm-2287733-18.patch, failed testing.

tim.plunkett’s picture

18: pm-2287733-18.patch queued for re-testing.

tim.plunkett’s picture

Status: Needs work » Fixed

Thanks @Berdir!

  • tim.plunkett committed cf22515 on 8.x-1.x authored by Berdir
    Issue #2287733 by Berdir, tim.plunkett: Added a configurable page title...
tim.plunkett’s picture

Status: Fixed » Needs work

Ughhh committed from the wrong tab.

  • tim.plunkett committed 041b101 on 8.x-1.x
    Revert "Issue #2287733 by Berdir, tim.plunkett: Added a configurable...
tim.plunkett’s picture

Status: Needs work » Needs review
StatusFileSize
new11.47 KB

Rerolled. Sorry for the confusion.

berdir’s picture

As discussed, I'm fine with leaving out the token UI and avoiding the module handler dependency, can also inject the token service for the replacements at the same time.

berdir’s picture

StatusFileSize
new13.53 KB
new3.04 KB

Ok, done as discussed.

Status: Needs review » Needs work

The last submitted patch, 27: pm-2287733-27.patch, failed testing.

tim.plunkett’s picture

Status: Needs work » Needs review
StatusFileSize
new13.24 KB
new1.08 KB
berdir’s picture

StatusFileSize
new13.7 KB

Re-roll.

berdir’s picture

StatusFileSize
new13.74 KB

And another re-roll.

Status: Needs review » Needs work

The last submitted patch, 31: pm-2287733-31.patch, failed testing.

dawehner’s picture

  1. +++ b/src/Plugin/DisplayVariant/BlockDisplayVariant.php
    @@ -70,6 +71,12 @@ class BlockDisplayVariant extends VariantBase implements ContextAwareVariantInte
     
       /**
    +   * The token service.
    +   *
    +   * @var \Drupal\Core\Utility\Token
    +   */
    +
    
    /**
     * The nothing.
     * 
     * @var mixed
     */
    

    Maybe adding a protected $token; would help ;)

  2. +++ b/src/Plugin/DisplayVariant/BlockDisplayVariant.php
    @@ -154,6 +166,15 @@ class BlockDisplayVariant extends VariantBase implements ContextAwareVariantInte
    +      '#default_value' => !$this->id() ? $this->executable->getPage()->label() : $this->configuration['page_title'],
    

    I wonder whether it would be possible to use the default_options for that?

  3. +++ b/src/Routing/PageManagerRoutes.php
    @@ -86,7 +86,6 @@ class PageManagerRoutes extends RouteSubscriberBase {
               '_page' => $entity_id,
    -          '_title' => $entity->label(),
             ),
    
    +++ b/tests/src/Unit/BlockDisplayVariantTest.php
    diff --git a/tests/src/Unit/PageManagerRoutesTest.php b/tests/src/Unit/PageManagerRoutesTest.php
    index b0a2c78..e1d0ed3 100644
    
    index b0a2c78..e1d0ed3 100644
    --- a/tests/src/Unit/PageManagerRoutesTest.php
    
    --- a/tests/src/Unit/PageManagerRoutesTest.php
    +++ b/tests/src/Unit/PageManagerRoutesTest.php
    
    +++ b/tests/src/Unit/PageManagerRoutesTest.php
    +++ b/tests/src/Unit/PageManagerRoutesTest.php
    @@ -115,9 +115,6 @@ class PageManagerRoutesTest extends UnitTestCase {
    
    @@ -115,9 +115,6 @@ class PageManagerRoutesTest extends UnitTestCase {
           ->method('getPath')
           ->will($this->returnValue('/page1'));
         $page1->expects($this->once())
    -      ->method('label')
    -      ->will($this->returnValue('Page label'));
    -    $page1->expects($this->once())
           ->method('usesAdminTheme')
           ->will($this->returnValue(TRUE));
         $pages['page1'] = $page1;
    @@ -143,7 +140,6 @@ class PageManagerRoutesTest extends UnitTestCase {
    
    @@ -143,7 +140,6 @@ class PageManagerRoutesTest extends UnitTestCase {
         $expected_defaults = array(
           '_entity_view' => '_page',
           '_page' => 'page1',
    -      '_title' => 'Page label',
         );
         $expected_requirements = array(
           '_entity_access' => '_page.view',
    @@ -192,7 +188,6 @@ class PageManagerRoutesTest extends UnitTestCase {
    
    @@ -192,7 +188,6 @@ class PageManagerRoutesTest extends UnitTestCase {
         $expected_defaults = array(
           '_entity_view' => '_page',
           '_page' => 'page1',
    -      '_title' => NULL,
         );
         $expected_requirements = array(
    

    Not really sure about this change. This kind of makes it impossible to render a page as part of a breadcrumb given that _title and _title_callback is used in order to generate those. If you specify #title, it will always win anyway. I wonder whether you could either use the $entity->label() or even the page title in case there is no token in there?

berdir’s picture

StatusFileSize
new13.86 KB
new1.57 KB

1. Completely overrated, I like the nothing more :)

Did not yet address 2 and 3, too tired to parse that.

This is already rerolled on top of the access/_page changes, so will not apply yet.

berdir’s picture

Status: Needs work » Needs review

Or it will because it was committed already :)

tim.plunkett’s picture

Status: Needs review » Needs work

I agree with #33.3, not sure what #33.2 means.

berdir’s picture

Not sure about #33.3, I'd consider the page label an administrative label that you don't want to show in the frontend? And the page label is part of the display now, so we don't know which one should be displayed?

berdir’s picture

Status: Needs work » Needs review
StatusFileSize
new13.83 KB

Reroll, not sure what you want me to do on 3.3 now :)

Status: Needs review » Needs work

The last submitted patch, 38: pm-2287733-38.patch, failed testing.

Status: Needs work » Needs review

tim.plunkett queued 38: pm-2287733-38.patch for re-testing.

Status: Needs review » Needs work

The last submitted patch, 38: pm-2287733-38.patch, failed testing.

tim.plunkett’s picture

Status: Needs work » Needs review
StatusFileSize
new13.43 KB

Rerolled

tim.plunkett’s picture

  1. +++ b/src/Plugin/DisplayVariant/BlockDisplayVariant.php
    @@ -145,6 +157,7 @@ public function build() {
    +    $build['#title'] = $this->renderPageTitle($this->configuration['page_title']);
    

    Why not wrap this in a conditional?

  2. +++ b/src/Routing/PageManagerRoutes.php
    @@ -86,7 +86,6 @@ protected function alterRoutes(RouteCollection $collection) {
    -          '_title' => $entity->label(),
    

    I think this could be kept, and just let the #title override it.

berdir’s picture

Reroll

1. Like this?
2. Ok. I think it is wrongproblematic to expose the admin title like this, but we can discuss this elsewhere instead of blocking this issue for a few more months ;) Added back and fixed unit tests.

Berdir queued 44: pm-2287733-44.patch for re-testing.

Status: Needs review » Needs work

The last submitted patch, 44: pm-2287733-44.patch, failed testing.

berdir’s picture

Status: Needs work » Needs review
StatusFileSize
new12.72 KB

Re-roll.

  • tim.plunkett committed 91de7e8 on 8.x-1.x authored by Berdir
    Issue #2287733 by Berdir, tim.plunkett: Added ability to configure page...
tim.plunkett’s picture

Status: Needs review » Fixed

Sorry for holding this up so long. Thanks @Berdir.

Status: Fixed » Closed (fixed)

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