Create a new dir_listing node using entity reference

Created on 14 July 2023, 12 months ago
Updated 1 August 2023, 11 months ago

Problem/Motivation

I want to auto create a dir_listing node using entity reference (Create referenced entities if they don't already exist)
The problem is the 'folder_path' is required during dir_listing node creation.

Steps to reproduce

Create a content type (client) and add a content reference field. (client files)
Select: Create referenced entities if they don't already exist
Under Content Type select: Directory listing
Save and create a (client) node
In the (client files) autocomplete field type "File1"
Save the (client) node.

This will show an error upon save.
But the Directory listing node named "File1" was created but the 'folder_path' is not set and it is required.
Setting the folder path and save fix the issue

Proposed resolution

Can administrators set a default path to use [using tokens] in the filebrowser administration UI

Uri of the directory: scheme://directory[/sub-directory]/[node-token]

If I am not mistaken then when the dir_listing node is created the 'folder_path' will be populated by the default administration path.
If it use tokens then the nid / date can be used for the folder naming to make sure unique folders are created each time.

There is this solution but you have to build your own module

Programmatically create a new dir_listing node β†’

✨ Feature request
Status

Closed: works as designed

Version

3.1

Component

Administrative Interface

Created by

πŸ‡ΏπŸ‡¦South Africa Vlooi Vlerke

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

Comments & Activities

  • Issue created by @Vlooi Vlerke
  • πŸ‡³πŸ‡±Netherlands clivesj

    Your request contains two parts:
    1. Provide default configuration for folder path.
    2. Accept token for the folder path.

    These two will indeed facilitate programmatically creation of directory listings.
    We can sure add a configuration for a default folder path.
    Please refer to
    https://www.drupal.org/project/filebrowser/issues/2941911 β†’
    to read the discussion on using tokens in the folder path. We have to make sure that once created, the directory name does not change accidentally due to a unstable token.

    I short time I have no time to work on this, but if you want to provide a patch, make sure to also include the update for the configuration in the install.yml file.

  • πŸ‡³πŸ‡±Netherlands clivesj
  • πŸ‡ΏπŸ‡¦South Africa Vlooi Vlerke

    Is it possible to populate β†’ the uri field from the url?

    I tried using the populate module β†’

    /node/add/dir_listing?edit[filebrowser_folder_path][widget][0][value]=private://user1folder
    

    If you can populate the uri then you can hide it from non admin users.

    This has nothing to do with entity reference but will assist amateurs in creating dir_listing nodes on the fly with no token support.

    Is this feasible, should I create a separate feature request?

  • πŸ‡³πŸ‡±Netherlands clivesj

    The fields on the dir-listing nodes are not real fields. The are injected on the node-create or edit form to create a Filebrowser object. that was a design choice early on on the design of the module. That is why Populate module will not work.

    It is definitely doable to make it work, but I will not be able to find time to work on it at this moment.

    If anyone wants to work on it please feel free to reopen this.

  • Status changed to Closed: works as designed 11 months ago
  • πŸ‡³πŸ‡±Netherlands clivesj
Production build 0.69.0 2024