File system storage
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 theme and 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
Please note that this is a storage-only option, and for creating and configuring Layouts and Post Selections, you still need to use the plugin's user interface.
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.
How to use it
You can enable and disable the File system storage in the plugin's Settings.
Folders structure
When you enable the File System Storage option, Advanced Views creates an "advanced-views" folder inside your active theme directory. This folder contains the following items:
"advanced-views" folder
This folder serves as the parent folder for all Layouts and Post Selections. Every Layout and Post Selection from the Advanced Views plugin has a dedicated sub folder.
"layouts" folder
Each Layout folder follows a specific naming structure: "layout-name_unique-id." For example, if you have a Layout with the title "ACF fields" and the unique ID "651d5d75bfdf2," then the folder name will be "acf-fields_651d5d75bfdf2."
Layout folder files
You can find information about the files inside the Layout folder below:
style.css
CSS code of the current Layout
CSS Code (CSS & JS tab)
style.scss (optional)
Sass code* (see the related chapter of this page)
-
script.js
JS code of the current Layout
JS Code (CSS & JS tab)
script.ts (optional)
TypeScript code* (see the related chapter of this page)
custom [.twig] [.blade.php]
Custom template of the current Layout
Custom template (Template tab)
default [.twig] [.blade.php]
Default template of the current Layout (note: for preview purposes only)
Default template (Template tab)
data.json
settings of the current Layout
-
links.md
Edit Layout link (allows to open the Layout's UI easily while editing inside IDE)
-
"post-selections" folder
This folder serves as the parent folder for all Post Selections. Every Post Selection from the Advanced Views plugin has a dedicated folder here.
Post Selections folder
Each Post Selection folder follows a specific naming structure: "post-selection-name_unique-id." For example, if you have a Post Selection with the title "Woo products" and the unique ID "651d5d75bfdf2," then the folder name will be "woo-products_651d5d75bfdf2."
Post Selection folder files
You can find information about the files inside the Post Selection folder below:
style.css
CSS code of the current Post Selection
CSS Code (CSS & JS tab)
style.scss (optional)
Sass code* (see the related chapter of this page)
-
script.js
JS code of the current Post Selection
JS Code (CSS & JS tab)
script.ts (optional)
TypeScript code* (see the related chapter of this page)
card.php
Custom data snippet of the current Post Selection (note: in Pro only)
Custom data (Advanced tab)
query-preview.php
WP_Query preview (note: for preview purposes only)
Query Preview (Template tab)
custom [.twig] [.blade.php]
Custom template of the current Post Selection
Custom template (Template tab)
default [.twig] [.blade.php]
Default template of the current Post Selection (note: for preview purposes only)
Default template (Template tab)
data.json
settings of the current Post Selection
-
links.md
Edit Post Selection link (allows to open the Post Selection's UI easily while editing inside IDE)
-
hidden files
".htaccess" file
Contains apache rules restricting direct access to all the files insides in browser.
".gitignore" file
When using Git: this file contains rules to exclude environment-specific files (such as links.md, which contains domain-specific information).
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.
Sass and TypeScript usage
Every Layout and Post Selection folder includes a style.css file for CSS code and script.js for JavaScript code. You have the option to use style.scss and script.ts files and compile them into style.css and script.js respectively. For a practical example, refer to the demo repository.
While Layout and Post Selection don't have fields in the UI representing style.scss and script.ts contents, these filenames are reserved and supported behind the scenes. This means that if you disable the FS and then enable it again, these files will be restored with their content. They are also supported in import/export and the Reusable Components library.
Tailwind usage
Tailwind is a great utility-first CSS framework, and with the File System storage active, you can use it in Layouts and Post Selection templates. For a practical example, refer to the demo repository. If you're building from scratch, check our starter theme with Tailwind.
Tailwind is fully supported by Advanced Views. While in many cases Tailwind is used in static builds where the list of elements is known during build time, this isn't the case with Layouts and Post Selections, as their appearance is controlled by the database.
To achieve this, the demo repository has a setup where every component have its own utility classes, while Tailwind globals are stored separately. Additionally, the utility classes that appear more than once are automatically merged by Advanced Views during rendering.
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