Support

Search results for ""

Sorry, no results found. Perhaps you would like to search the documentation?
All Topics
signelazer

use local storage

Hi, I’d like to use local storage to avoid database queries as much as possible.

I’ve tested the following code, but no file is created in the folder.

// ADVANCED COLUMNS PRO
add_filter('acp/storage/file/directory', function () {
	// Use a writable path, directory will be created for you
	return get_stylesheet_directory() . '/back-end/acp';
});
add_filter('acp/storage/file/directory/writable', '__return_false');

add_filter('acp/storage/file/directory/migrate', '__return_true');

I also tried a code to generate php file, it’s work but i think it’s better with .json, and i just reduced one request from DB, this is the code:

add_filter(
	'acp/storage/repositories',
	function (array $repositories, ListScreenRepositoryFactory $factory) {
		$post_types = ['post', 'project', 'lieu', 'map', 'contact', 'movie', 'wp-media', 'page'];
		foreach ($post_types as $pt) {
			$rules = new Rules();
			$rules->add_rule(new Rule\EqualType($pt));
			$repositories[$pt] = $factory->create(
				get_stylesheet_directory() . "/back-end/acp/${pt}",
				true,
				$rules
			);
		}
		return $repositories;
	},
	10,
	2
);

Any advices, what i’m doing wrong

Thank you in advance

11 months, 3 weeks ago
Stefan van den Dungen Gronovius
Developer

First about the first try/setup/
For a migration to run, the new file storage must be writable.
So when you put the storage on writable, it should migrate.
Unfortunately, the migration is currently broken (just tested) and I recommend the following workaround:

1) Export all your list screens from the database with the Migrate tool on our settings page to 1 JSON file.
2) Put the file repository in write mode
3) Now import the JSON file on the migration page
4) All settings will now be stored as PHP files in the configured directory.

So to be clear, both options write PHP files, not JSON!
Only our export files are in JSON format.

You can leave the write mode enabled if you want to skip the database for writing the settings

11 months, 3 weeks ago
René

Thanks. This worked also for me. I was just a bit lost to migrate over to the file based approach because it wasn’t saving on update. But on the export/import it started to write. And since then things make sense ;-)

10 months, 3 weeks ago

You must be logged in to reply to this topic.