Martijn Geerts

Admin Custom Files

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.

 

 

 

Share this post


Link to post
Share on other sites

Thx for info and for legacy link. I must be lucky since I drive like 5 mins to work :-) 

Share this post


Link to post
Share on other sites

You can load JS/CSS with AOS, isn't that an option?

Share this post


Link to post
Share on other sites
15 hours ago, tpr said:

You can load JS/CSS with AOS, isn't that an option?

Of course. And I can do it even without AOS ;-) 

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

@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 1

Share this post


Link to post
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!

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

I can't seem to go past 0.9.4, i always get this error screen of death:

Compile_Error__Cannot_use_isset___on_the_result_of_an_expression__you_can_use__null_____expression__instead_.thumb.jpg.5cece06398d762795337a8c9c89949e8.jpg

  • Thanks 1

Share this post


Link to post
Share on other sites

@Macrura What is $ext at that moment?

Could you try to replace the isset line with:

		if ($ext !== 'js' && $ext !== 'css') return false;

 

Share this post


Link to post
Share on other sites

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..

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
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

Share this post


Link to post
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...

Share this post


Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By blad
      Hi guys!
      I just uploaded a module to explore files based on elFinder. By default it will show the "Files" folder.
      Screenshots:

      Video:
       
      To do:
       More options To fix:
       The function of rotating or scaling an image fails  Image editors Github:
      https://github.com/LuisSantiago/ProcessElFinder/
      I hope you like it.
    • By BitPoet
      I'm really in love with FormBuilder, but the one thing missing to match all my end users' expectations were repeatable field groups. Think repeaters, in ProcessWire terms. Our primary application of PW is our corporate intranet, so "lines" of fields are quite common in the forms I build. We have all kinds of request forms where the information for a varying number of colleagues needs to be entered (from meal order to flight booking request) and where it is simply impractical to send a form for each, and I don't want to clutter my forms with multiple instances of fields that may only get used ten percent of the time.
      That's why I started to build FormBuilderMultiplier (link to GitHub).
      What it does:
      Adds an option to make a regular Fieldgroup repeatable Lets you limit the number of instances of a Fieldgroup on the form Adds an "Add row" button the form that adds another instance of the Fieldgroup's fields Adds a counter suffix at the end of every affected field's label Stores the entered values just like regular fields Makes the entered values available in preview and email notifications Supports most text based fields, textareas and selects (really, I haven't had enough time to test all the available choices yet) What it doesn't do (yet):
      Support saving to ProcessWire pages (i.e. real Repeaters) I haven't tested all the validation stuff, Date/Time inputs etc. yet, but since I'm utterly swamped with other stuff at work, I didn't want to wait until I have it polished. Any feedback is welcome. There might also be some issues with different output frameworks that I haven't encountered yet. The forms I work with mostly use UIKit.
      Status:
      Still alpha, so test well before using it in the field.
      Known issues:
      When rows are added, the form's iframe needs to be resized, which isn't completely clean yet.
      How it works:
      The Fieldgroup settings are added through regular hooks, as is the logic that adds the necessary field copies for processing the form and displaying previews.
      "Multiplied" field instances are suffixed with _NUM, where NUM is an incremental integer starting from 1. So if you have add two fields named "surname" and "givenname" to a fieldgroup and check the "multiply" checkbox, the form will initially have "surname_1" and "givenname_1" field (I'm still considering changing that to make the risk to shoot oneself into the foot by having a regular "surname_1" field somewhere else in the form less likely).
      When a "row" is added, the first row is cloned through JS and the counter in the fields' IDs, names and "for" attributes as well as the counter in the label are incremented before appending the copies to the Fieldset container in the form.
      To keep backend and frontend in sync, a hidden field named [name of the fieldset]__multiplier_rows is added to the form. Both the backend and the frontend script use this to store and retrieve the number of "rows".
      ToDo:
      Naturally, add the option to store the data in real repeaters when saving to pages. Do a lot of testing (and likely fixing). Make a few things (like the "Add row" button label etc.) configurable in field(set) context. Add a smooth API to retrieve the multiplied values as WireArrays. The mandatory moving screenshot:

    • By MoritzLost
      Hello there,
      I'm working on a tiny textformatter module that searches the text for titles of other pages on your site and creates hyperlinks to them. I'm not sure if something like this exists already, but I haven't found anything in the module directory, so I wrote my own solution 🙂
      It's not properly tested yet and is still missing some functionality I would like to implement, so at the moment it should be considered in BETA. Features include limiting the pages that will get searched by template, and adding a custom CSS class to the generated hyperlinks. As I'm writing this I noticed that it will probably include unpublished and hidden pages at the moment, so yeah ... it's still in development alright 😅
      You can download the module from Github:
      https://github.com/MoritzLost/TextformatterPageTitleLinks
      There's some more information in the readme as well.
      Anyway, let me know what you think! I'm happy about any feedback, possible improvements or ideas on how to improve the module. Cheers.
    • By adrian
      This module provides a way to rapidly generate Page fields and the required templates and pages for use as a drop down select (or any other Page field type).
      This module will let you create a full page field setup in literally a few seconds 
      To use, run Page Field Select Creator from the Setup Menu
      Enter a Field Title, eg: Room Types Select Options - These will become the child pages that will populate the page field select options. There are two different options.
       
      Option 1. TITLE FIELD ONLY - enter one option per line, eg:
       
      Single
      Double
      Suite
       
       
      Option 2. MULTIPLE FIELDS - the first line is used for the field names and the first field must be 'Title'. Subsequent lines are the values for the fields, eg:
       
      Title, Number of Beds, Number of People, Kitchen Facilities
      Single, 1, 1, Fridge Only
      Double, 2, 2, Fridge Only
      Suite, 3, 6, Full Kitchen
        Choose the parent where the page tree of options will be created, eg a hidden "Options" parent page Select a "Deference in API as" option depending on your needs Choose the input field type Check whether "Allow new pages to be created from field?" should be enabled. As an example, if you entered "Room Types" as the field title, you would end up with all of the following automatically created:
      a fully configured page field called: room_types MULTIPLE FIELDS OPTION - 3 additional fields - number_of_beds, number_of_people, kitchen a parent template called: room_types a child template called: room_types_items (with either just a title field, or with the 3 additional fields as well) a parent page called: Room Types a series of child pages named and titled based on the per line entries in the Select Options textarea The templates are configured such that the "room_types_items" child template can only have the main "room_types" template as a parent, and vice versa.

      Then all you have to do is add the newly created page field to any template you want and you're ready to go!
       
      You can grab it from:
       
      Modules directory: http://modules.processwire.com/modules/process-page-field-select-creator/
      Github: https://github.com/adrianbj/ProcessPageFieldSelectCreator
       

    • By bernhard
      WHY?
      This module was built to fill the gap between simple $pages->find() operations and complex SQL queries.
      The problem with $pages->find() is that it loads all pages into memory and that can be a problem when querying multiple thousands of pages. Even $pages->findMany() loads all pages into memory and therefore is a lot slower than regular SQL.
      The problem with SQL on the other hand is, that the queries are quite complex to build. All fields are separate tables, some repeatable fields use multiple rows for their content that belong to only one single page, you always need to check for the page status (which is not necessary on regular find() operations and therefore nobody is used to that).
      In short: It is far too much work to efficiently and easily get an array of data based on PW pages and fields and I need that a lot for my RockGrid module to build all kinds of tabular data.

      Basic Usage

       
      Docs & Download
      https://modules.processwire.com/modules/rock-finder/
      https://github.com/BernhardBaumrock/RockFinder
       
      Changelog
      180817, v1.0.6, support for joining multiple finders 180810, v1.0.5, basic support for options fields 180528, v1.0.4, add custom select statement option 180516, change sql query method, bump version to 1.0.0 180515, multilang bugfix 180513, beta release <180513, preview/discussion took place here: https://processwire.com/talk/topic/18983-rocksqlfinder-highly-efficient-and-flexible-sql-finder-module/