At admin/structure/book you get a list of books with the option to 'Edit order and titles'. If you click this for an unpublished book, the child pages do not display in the list regardless of whether they are published or not. Additionally, unpublished child pages don't display even if their parent is published.

Steps to reproduce:

  1. Install Drupal
  2. Enable book module
  3. Create a book page, unpublished
  4. Create a child book page of this (published or unpublished - doesn't matter)
  5. Create a book page, published
  6. Create a child book page of this, published
  7. Go to admin/structure/book
  8. Click 'Edit order and titles' for the published book, confirm you can see the child page
  9. Click 'Edit order and titles' for the unpublished book, confirm you cannot see the child page
  10. Further, unpublish the child created in #6
  11. Click 'Edit order and titles' for the published book, confirm you can no longer see the child page now that it is unpublished

Comments

-enzo-’s picture

Status: Active » Needs review
StatusFileSize
new1.66 KB

Hello guys

I just created a new patch to solve this feature requested.

Please test and let me know if works for you.

estebanvalerio.h’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +dlatino, +drupalcr

Reviwed on drupal contribute Costa Rica

Anonymous’s picture

develcuy’s picture

Status: Reviewed & tested by the community » Needs work

good to go, let's add a nice unit test to the patch :)

yoroy’s picture

Priority: Minor » Normal

Thanks for working on this. A screenshot would help: how can I see if a book is published or not?

kscheirer’s picture

Needs some minor code style cleanup, spaces between commas in arrays, spaces between ternary operator, and don't just comment out the old code, remove it.

develcuy’s picture

Priority: Normal » Minor
Status: Needs work » Needs review
StatusFileSize
new1.63 KB

Code styling improvements.

Status: Needs review » Needs work
Issue tags: -dlatino, -drupalcr

The last submitted patch, list-publish-unpublish-books-1184692-7.patch, failed testing.

-enzo-’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work
Issue tags: +dlatino, +drupalcr

The last submitted patch, list-publish-unpublish-books-1184692-7.patch, failed testing.

Anonymous’s picture

ok guys. I just do the patch again, because the last version was broken.
In this case, I'll attach an screenshot that you can see the list of books (all) and your respective status

screenshot

-enzo-’s picture

Status: Needs work » Reviewed & tested by the community

The last submitted patch, list-all-books-in-admin-section-1184692-7.patch, failed testing.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

ptmkenny’s picture

Version: 8.8.x-dev » 9.1.x-dev
Issue summary: View changes
Related issues: +#26552: Allow users with access to unpublished nodes to create unpublished books
ramya balasubramanian’s picture

Assigned: Unassigned » ramya balasubramanian
ramya balasubramanian’s picture

Hi @wjaspers, @ptmkenny,

I have checked this issue still exists in 9.1 dev. So I have created the patch and added screenshots before and after the patch. Please have a look and let me know if there are any issues.

Before Patch:

See the Book and parent item of the node

test

test

After Patch:

test

sharma.amitt16’s picture

Status: Needs review » Needs work

@ramya thanks for the patch and it is working fine. Would you please add a status column on the page as already done in previous patches.

ramya balasubramanian’s picture

Status: Needs work » Needs review
StatusFileSize
new1.76 KB
new361.54 KB

Hi @sharma.amitt16,

I have addressed your above comments. Please have a look.


After Patch:

test

sharma.amitt16’s picture

Status: Needs review » Needs work
+++ b/core/modules/book/src/Form/BookAdminEditForm.php
@@ -148,6 +148,7 @@ protected function bookAdminTable(NodeInterface $node, array &$form) {
         $this->t('Operations'),

@ramya thanks for the change. Small correction, would you please move the operations column after status.

This is not consistent with other content listing with operations.

ramya balasubramanian’s picture

Status: Needs work » Needs review
StatusFileSize
new2.09 KB
new358.65 KB

Hi @sharma.amitt16,

Updated the patch and screenshots.

test

sharma.amitt16’s picture

+++ b/core/modules/book/src/Form/BookAdminEditForm.php
@@ -147,6 +147,7 @@ protected function bookAdminTable(NodeInterface $node, array &$form) {
+        $this->t('Status'),
         $this->t('Operations'),

Now looks good.

priyanka.sahni’s picture

Assigned: Unassigned » priyanka.sahni
priyanka.sahni’s picture

StatusFileSize
new290.96 KB

Verified and tested by applying the patch #27.It looks good to me.Can be moved to RTBC.

Steps to test -
1. Go to admin site.
2. Go to admin/modules , enable the book module.
3. Go to admin/content.
4. Create 2-3 book content type.
5. Create one of them in unpublished state and other in published state.
6. Go to admin/structure/book.
7. Verify the listing.

Patch#27

Before Patch -
BeforePatch

After Patch -
AfterPatch

priyanka.sahni’s picture

Assigned: priyanka.sahni » Unassigned
kscheirer’s picture

Status: Needs review » Reviewed & tested by the community

Based on #30.

priyanka.sahni’s picture

StatusFileSize
new160.17 KB
new211.53 KB
catch’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests
@@ -959,7 +959,6 @@ public function bookTreeCheckAccess(&$tree, $node_links = []) {
       //   field language and just fall back to the default language.
       $nids = \Drupal::entityQuery('node')
         ->condition('nid', $nids, 'IN')
-        ->condition('status', 1)
         ->execute();
 
       foreach ($nids as $nid) {

Do we need to check that the current user has access to view unpublished nodes? What's the route access for this page?

Also there's no test coverage added with this patch but probably should be.

ramya balasubramanian’s picture

Hi @catch,
Thanks. Sorry for the delayed reply. I have checked your comment and already there is one issue related to access to unpublished nodes (https://www.drupal.org/project/drupal/issues/26552). And in this issue https://www.drupal.org/project/drupal/issues/26552, in the last updated patch(https://www.drupal.org/files/issues/2020-03-18/26552-156.patch) they have added test cases for listing book pages testAdminBookListing, testAdminBookNodeListing.

Is this enough or do we need to create seperate test cases for this issue also? Please let me know.

pameeela’s picture

Title: List of books at "admin/content/book" doesn't show Unpublished books » Unpublished books can't be reordered at admin/structure/book/[bookid]
Category: Feature request » Bug report
Issue summary: View changes
Issue tags: +Bug Smash Initiative

Updated title and issue summary - admin/content/book does not seem to exist, I worked out what is going on though :)

Changing to a bug, not a feature request as there is no reason this shouldn't work for unpublished content.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

andypost’s picture

  1. +++ b/core/modules/book/src/Form/BookAdminEditForm.php
    @@ -211,6 +212,7 @@ protected function bookAdminTableTree(array $tree, array &$form) {
    +      $node = \Drupal\node\Entity\Node::load($nid);
    

    Use $this->nodeStorage->load() instead

  2. +++ b/core/modules/book/src/Form/BookAdminEditForm.php
    @@ -267,6 +269,11 @@ protected function bookAdminTableTree(array $tree, array &$form) {
    +      $form[$id]['status'] = [
    +        '#type' => 'markup',
    +        '#markup'=> $node->isPublished() ? 'Published' : 'Unpublished',
    
    @@ -288,6 +295,11 @@ protected function bookAdminTableTree(array $tree, array &$form) {
    +      $form[$id]['status'] = [
    +        '#type' => 'markup',
    +        '#markup'=> $node->isPublished() ? 'Published' : 'Unpublished',
    

    Overall not sure it's needed but

    - no reason to duplicate status column
    - strings should use $this->t() to be translatabe

anchal_gupta’s picture

Status: Needs work » Needs review
StatusFileSize
new1.25 KB
new1.25 KB

I have uploaded the patch.
Addressed #42 both points,
Rerolled against 10.1x

mstrelan’s picture

Status: Needs review » Postponed (maintainer needs more info)
Issue tags: +Needs steps to reproduce

I cannot reproduce this on 10.1 following the steps in the issue summary. It might be worth noting that I was logged in as user 1, do we need to use a certain role with certain permissions. Can someone who can reproduce this please provide updated steps to reproduce?

Furthermore we need a failing test to confirm this behaviour.

quietone’s picture

Status: Postponed (maintainer needs more info) » Closed (outdated)

I tested this on Drupal 10.1.x, standard install. I used the steps in the Issue Summary. First, I tested with the admin user and I was not able to reproduce the problem. Next, I created a user that had permission to create books, edit own books, administer content, view own unpublished content and the necessary admin book permissions. Again, I could not produce the error.

This may have been fixed as part of #26552: Allow users with access to unpublished nodes to create unpublished books but #21 and the testing just after suggests otherwise.

Therefore, closing as outdated. If you are experiencing this problem on a supported version of Drupal reopen the issue, by setting the status to 'Active', and provide complete steps to reproduce the issue (starting from "Install Drupal core").

Thanks!