Jump to content

Admin Custom Files


Martijn Geerts

Recommended Posts

@matjazp If you need the old AdminCustomFiles: https://github.com/Da-Fecto/AdminCustomFilesLegacy

There's so much changed in the admin of PW3 so AdminCustomFiles (the old) would not fully work in PW3 without a lot of extra code. Thereby I think we should move on and drop non namespaced PW.  Then there's the reason I have/had ~~almost~~ no spare time this year. We restaurated our old house (stripped bare & build up), next I had a job, for 40 hours a week plus the insane driving hours to the job.

 

 

 

Link to comment
Share on other sites

  • 4 weeks later...

Hi @Martijn Geerts

This module does not upgrade cleanly from earlier versions. For instance, in earlier versions the Dependencies field was a textarea with each dependency separated by newline. In more recent versions, JSON data is expected for this field value. So after upgrading the module config page doesn't render properly due to a JS error when attempting to decode the field data. To fix this I have to edit the module config data directly in phpMyAdmin.

Could you please add an upgrade() method to the module to translate module config values from earlier versions to the current format?

  • Like 1
Link to comment
Share on other sites

  • 9 months later...

I upgraded to 0.9.4 without thinking. I don't think I had any newline-separated dependencies, only a config.js, but I am still getting an error.

In the db, modules, AdminCustomFiles, the data field has

{"files_folder":"AdminCustomFiles","process_filter":["ProcessPageAdd","ProcessPageEdit"],"js_config":1,"theme_files":"","dependencies":"AdminCustomFiles\/config.js"}

When I am in the module config page, I get this in the console:

"SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data" pointing to the line with data = input.value ? JSON.parse(input.value) : [],

Being in debug mode, I get this on all admin pages: Warning: Invalid argument supplied for foreach() in /path/to/site/modules/AdminCustomFiles/AdminCustomFiles.module on line 249

What should I do?

Link to comment
Share on other sites

24 minutes ago, Macrura said:

@Beluga

i found that if you run into a problem with upgrading this, it works to uninstall the old one, and then install the new one; you can take a screenshot to remember your settings from old version

Thanks. I had to delete the row from the modules db table and then I was able to reinstall it. Works now!

Link to comment
Share on other sites

Hi @Martijn Geerts,

ran into an issue with ACF issuing notices on L123 of AdminCustomFiles.module due to unguarded access of the "theme" and "process" indexes on the index array.

Changed code to:

if (isset($this->index['theme'])) {
	foreach ($this->index['theme'] as $prop) $config->get($prop['type'])->add($prop['url']);
}
if (isset($this->index['process'])) {
	foreach ($this->index['process'] as $prop) $config->get($prop['type'])->add($prop['url']);
}

to fix this.

  • Like 2
Link to comment
Share on other sites

  • 2 weeks later...

Hi Guys,

AdminCustomFiles received some well-deserved love. (an update to version 0.9.61)

There were several bug fixes and some major changes. I did break compatibility on several aspects of this module but after this update everything should be fine.

- You can upgrade from 0.8.7 and below. (we take care of all settings) 
- The JSON output is now fully customizable. 

Previously I hooked *ProcessController::execute* and inserted the files to the config->scripts and files but with ProcessWire 3.x these were not the last files. Now we use Page::render to insert the files that should fix it.

For the config.AdminCustomFiles javascript object we now have a base class that can be extended easily. When you created the class, you can select the class and save the module configuration. More info in the module configuration and in the example class below.

/**
 * AcfConfigCustom
 *
 * Create a file in your AdminCustomFiles folder and start the filename with
 * ‘AcfConfig’ then ‘a custom name’ and add ‘.php’.
 *
 * In this file create a class with the basename of the file without the
 * extension. This class should extend AcfConfig and implements Module.
 *
 * Properties of the subclass
 *
 * @var AdminCustomFiles	$adminCustomFiles	Instance of AdminCustomFiles may you need it.
 * @var Page|NullPage		$editPage			In processPageEdit it would be the page you are editting.
 * @var Template			$editTemplate		Template from the page above.
 */
class AcfConfigCustom extends AcfConfig implements Module {

	/**
	 * Optional ready method
	 *
	 * - Use it or leave out.
	 * - We call ready() before calling jsConfig().
	 */
	public function ready() {}

	/**
	 * Required jsConfig method
	 *
	 * Return a PHP array ready to be used for $config->js
	 *
	 * @return array
	 */
	public function jsConfig() {
		$process = $this->wire('process');
		return array(
			"activeProcess" => $process->className(),
			"editPage" => $this->editPage->id,
			"editTemplate" => $this->editTemplate->name,
		);
	}
}

 

  • Like 4
Link to comment
Share on other sites

When Trying to install i get this error :

Quote

Compile Error: require(): Failed opening required '/volume1/web/dokuverwaltung/site/modules/AdminCustomFiles/acfConfig.php' (include_path='.') (line 91 of /volume1/web/dokuverwaltung/site/modules/AdminCustomFiles/AdminCustomFiles.module)

It seems he is trying to load  acfConfig.php while the file is called AcfConfig.php .

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

not sure, this just happens when i try and install the new version; It may be something to do with the settings? I always uninstall the 0.8.7 and then do a clean install of the 0.9.4; then i noticed the upgrade, ran that from the upgrades module and got this screen, so i'm not interacting with the module, but i could try clearing out everything int he AdminCustomFiles folder and see if that helps..

Link to comment
Share on other sites

23 hours ago, Martijn Geerts said:

Actually I don't understand the error, the only thing I can imagine is that ext is not there... 

Are you willing to replace the isset line with the code above? 

yes, will test later today.

2 hours ago, NorbertH said:

Whats your PHP version ? 

the sites with the error are all running 5.6; the sites running 7.x seem to work ok with past 0.9.4

  • Like 1
Link to comment
Share on other sites

6 hours ago, Martijn Geerts said:

Thanks @Macrura, I will update the module to make it backwards compatible with old PHP soon....

Ok cool, thanks, I just realized i can't install on those sites because it basically tanks the whole site, even the front end...

Link to comment
Share on other sites

  • 2 years later...

Not sure why this is happening, but I can't use the latest version on Mac OS, local development (i can only use the 0.8.7).

The module doesn't seem to understand the paths - i can't actually add dependencies, even though I know i'm adding the correct path, i even copied all of the dependency files into the ACF folder and it still report that it can't find the file and it won't add the dependency. Relative to ACF folder also can't use something like ./ to get to templates.

If i put in the root relative path, the module outputs the wrong url to the file, it puts the subdomain twice.

here is an example, on localhost, the root URL is http://localhost:8888/ and the subdomain is processwire_test1

the root relative url is presumably "/processwire_test1/site/templates/libraries/path-to-some-file.js" but the module outputs this:

processwire_test1/processwire_test1/site/templates/libraries/path-to-some-file.js

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...