Missing content types on node/add page

Created on 16 September 2018, over 6 years ago
Updated 20 March 2025, 21 days ago

Problem/Motivation

On as standard install, when a user with only the 'administer content types' navigates to /node/add the message displayed is

You have not created any content types yet. Go to the content type creation page to add a new content type.

which does not make sense in this case when there are two content types, Article and Page.

Original issue summary
The page should list all content types if a user has 'administer content types' permission. That would match NodeAddAccessCheck::access() implementation. Currently a user with permission to administer content types can always access node/add/{content_type} page while the content type may not present on node/add page.

Steps to reproduce

Create a user with only the 'administer content types'
Log in as that user
Navigate to /node/add

Proposed resolution

Show the user a meaningful message based on the permissions.

Remaining tasks

Agree on the text
Make a patch
Review
Commit

User interface changes

Yes
before and after screenshost to be added

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Active

Version

11.0 🔥

Component

node system

Created by

🇷🇺Russia Chi

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇦🇺Australia acbramley

    This is still relevant, surprisingly the "You have not created any content types yet" message is hardcoded in the node-add-list twig template which is duplicated across 4 themes in core.

    IMO this would ideally be in NodeController::addPage but that's probably going to be harder to get in.

    Instead we can do something like this in the controller:

      if (count($types) > 0 && count($content) === 0 && $user->hasPermission('administer content types')) {
        // Return a hardcoded message, including cacheable metadata for permissions and the node_type list tag.
      }
    
Production build 0.71.5 2024