cms icon indicating copy to clipboard operation
cms copied to clipboard

Templates don't show up in dropdown on Collection setting pages after renaming 'Views' directory

Open architchandra opened this issue 2 years ago • 1 comments

Bug description

I have a strong preference for a particular folder structure and nomenclature for templates (inspired by Craft CMS and https://github.com/miranj/craft-boilerplate/tree/dev/templates). I was really happy to see that there was a config/view.php file that seemed to be a simple step towards achieving this folder structure.

I changed to the following:

'paths' => [
        resource_path('templates'),
    ],

'compiled' => env(
        'VIEW_COMPILED_PATH',
        realpath(storage_path('framework/compiled_templates'))
    ),

Unfortunately, I am noticing the following issues:

  • Existing templates no longer show up in Collection settings. Just a Map to Blueprint option appears.
  • The partial tag is no longer able to fetch anything.

Upon checking the source code for Statamic CMS, it seems that there are a lot of places where resources/views is hard-coded. I'm guessing that the config/view.php values are not being used everywhere.

I don't really have much experience with either Statamic or Laravel. Am I missing something obvious?

How to reproduce

  • Change the config in config/view.php.
  • Rename the views folder to templates and the storage/framework/views folder to storage/framework/compiled_templates.
  • Open an existing collection's setting and try to update the template path there. The dropdown would be empty except a Map to Blueprint option.
  • To still make the template work for that collection's entries, add the correct template path in the collection's yaml file.
  • Add a partial to the template. That partial's contents would not be fetched.

Logs

No response

Environment

Environment
Application Name: Statamic
Laravel Version: 9.26.1
PHP Version: 8.1.9
Composer Version: 2.4.1
Environment: local
Debug Mode: ENABLED
URL: <project_name>.test
Maintenance Mode: OFF

Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: NOT CACHED

Drivers
Broadcasting: log
Cache: statamic
Database: mysql (not changed from .env but not using a DB)
Logs: stack / single
Mail: smtp
Queue: sync
Session: file

Statamic
Addons: 0
Antlers: runtime
Version: 3.3.32 Solo

Installation

Fresh statamic/statamic site via CLI

Antlers Parser

runtime (new)

Additional details

No response

architchandra avatar Sep 06 '22 07:09 architchandra

Update: I'm not sure what I did (perhaps there was some content or collection setting issue) but the templates and partials started working again. Existing templates, however, are still not showing up in the dropdown on Collection setting pages. They have to be set in the corresponding yaml files manually.

architchandra avatar Sep 06 '22 09:09 architchandra