File System storage feature
1. About the feature
By default, Layouts and Post Selection are stored in the database. The File system storage allows you to store Layouts and Post Selection data as files inside your child theme.
Important: you should use a child theme, otherwise automatic theme updates will erase the data.
File system storage has the following advantages over the Database method:
IDE compatible You can amend code in your favorite IDE
GIT compatible You can track changes using Git or another tool. In addition, you can automatically delivery changes to Live
Sass and TypeScript compatible You can extend the default CSS to Sass for JS to TypeScript
Tailwind support You can use Tailwind in the templates
Keep in mind that this is a storage-only option, and for creating and configuring Layouts and Post Selections, atm you still need to use the plugin's user interface.
Note: this feature is UI-compatible, which means after activating, you can amend code in both ways, using your IDE or the on-site editor within your Layouts or Post Selections.
2. How it works
Layouts and Post Selections are Custom Post Types (CPTs), and their items store their settings as JSON in the "post_content" field of the "wp_posts" table (for better performance). When File System (FS) storage is enabled, Layout and Post Selection settings are stored inside your theme folder. While their settings are still stored as JSON, they exclude all code-related fields, which are converted into separate files to make them easily editable.
Note: When you enable File System storage, you still create and configure Layouts and Post Selections using the plugin's UI. The plugin creates posts for them but stores their settings inside your theme folder instead of the "post_content" field in the database. This allows you to benefit from the UI during creation and configuration and take advantage of your IDE when editing.
3. How to manage it
You can enable and disable the File system storage in the plugin's Settings.
4. Template validation
When you make changes to the templates using your IDE, the plugin's template validation, which runs automatically during the 'save' process, is not triggered.
You should rely on your IDE's validation while editing a template.
Tip: You can perform a bulk template validation by going to the Layout/Post Selection list table and switching to the 'Bulk validation' tab. This process validates the Custom Template field for all existing items and displays items that have failed validation.
5. Auto sync
If you're using version control in your project, such as Git, you can also consider using the File System storage option as a way to automatically deliver changes from your development environment to your live websites.
Since File System storage contains all the Layout and Post Selection settings, you can modify Layouts and Post Selections on your development website, save (push) the changes to your version control repository, and then update (pull) those changes on your live website.
This process will automatically deliver all the changes made to Layouts and Post Selections to the live website without the need for manual updates or import/export procedures.
Sync of FS-only items
If you have created Layouts or Post Selections on your Dev website and then launched them to Live using Git, these items will appear in FS-only mode. They will function like regular items, but you won't be able to edit them using the UI because the corresponding posts are missing.
If you need to make modifications to these items on your live website using the plugin's UI, you will need to 'sync' the target items. To do this, visit the Layouts/Post Selections list table, click on the "FS only" tab, and then click 'sync' in the row of the target item or perform a bulk sync.
The 'sync' process will create WordPress posts for the selected Layouts or Post Selection, enabling you to make changes using the plugin's UI. Rest assured, the Layout or Post Selection data will still be stored in the Filesystem.
Auto-removal for DB-only items
When you activate the File system storage, Advanced Views stores all Layouts and Post Selections data in the File system while utilizing the database (WordPress posts) only for UI-related things. So, if you delete a Layout or Post Selection folder in your File system, Advanced Views will automatically remove the corresponding DB-related post when you visit the Layouts or Post Selections list table.
This means that if you've launched a Layout or Post Selection to Live using Git, then performed a 'sync' to make changes to the item, and subsequently removed that item in File system in the next release, Advanced Views will automatically delete the related post, sparing you the need for manual tracking.
Last updated