Macrura Posted January 27, 2023 Author Share Posted January 27, 2023 @gornycreative thanks - the use case sounds interesting and obviously useful for dynamically generating options from other places than static choices; I'll play around with it soon and try and post back, have some projects that will probably need more elaborate settings pages soon... Link to comment Share on other sites More sharing options...
gornycreative Posted January 27, 2023 Share Posted January 27, 2023 If you want to try the example I built (it looks for css/less files in assets/fonts and templates/ and then parses font families and returns a select options box with unique path/font family pairs) let me know and I'll tidy up an example and attach it. On the backend it gives me this: 2 1 Link to comment Share on other sites More sharing options...
Macrura Posted January 31, 2023 Author Share Posted January 31, 2023 yeah looks very cool @gornycreative Perhaps if you don't mind sharing it, it would be great to have a look! - this is somewhat the original intention of the module, to be able to provide all of those types of settings interfaces like people build for WordPress etc.. 2 Link to comment Share on other sites More sharing options...
Krlos Posted July 19, 2023 Share Posted July 19, 2023 Hi @Macrura, I just found your amazing module, how can I enable multilanguage support for fields? Thanks. Link to comment Share on other sites More sharing options...
Macrura Posted July 19, 2023 Author Share Posted July 19, 2023 On 7/19/2023 at 2:11 PM, Krlos said: Hi @Macrura, I just found your amazing module, how can I enable multilanguage support for fields? Thanks. Expand Hi Krlos - thanks - I believe the module does support multilanguage, and we had added support for that a few years ago. I know there is probably no example of how to set a multilanguage field in the samples, but AFAIK it should work if you get the JSON or PHP setup to tell it the various language parameters. 1 Link to comment Share on other sites More sharing options...
froot Posted September 27, 2023 Share Posted September 27, 2023 has something changed in this module? Because I cannot seem to find the place where you enter the path to the json or php file with the settings array. I'm on ProcessWire 3.0.207 Link to comment Share on other sites More sharing options...
Macrura Posted September 27, 2023 Author Share Posted September 27, 2023 On 9/27/2023 at 8:17 PM, fruid said: has something changed in this module? Because I cannot seem to find the place where you enter the path to the json or php file with the settings array. I'm on ProcessWire 3.0.207 Expand @fruid First create a new admin page (under admin, with admin template) and then select ProcessSettingsFactory as the process. After that you'll see the Inputfields Definition File Path field show. Link to comment Share on other sites More sharing options...
froot Posted September 27, 2023 Share Posted September 27, 2023 yes of course, I remember now Thanks! 1 Link to comment Share on other sites More sharing options...
froot Posted September 27, 2023 Share Posted September 27, 2023 On 12/27/2017 at 1:58 PM, Zeka said: 'useLanguages' => true, Expand I tried that, FYI I see PHP Warning: Undefined array key "footer_imprint__1021" in .../modules/SettingsFactory/ProcessSettingsFactory.module:151 Link to comment Share on other sites More sharing options...
Macrura Posted September 28, 2023 Author Share Posted September 28, 2023 On 9/27/2023 at 10:48 PM, fruid said: I tried that, FYI I see PHP Warning: Undefined array key "footer_imprint__1021" in .../modules/SettingsFactory/ProcessSettingsFactory.module:151 Expand Yes i see that the lines that handle the languages (148-154) is not checking if the array key is set yet. Will have to add that check to prevent the warning. 2 Link to comment Share on other sites More sharing options...
froot Posted September 29, 2023 Share Posted September 29, 2023 I know I'm sort of preaching to the choir here, but it's a shame you cannot add images in SF. I think what many devs, me included ,want to use this module for is for global settings which includes things like logo(s). It just makes so much more sense to have these things defined in a separate page rather than by adding fields to the home template but maybe I'm just being too neurotic. Please forgive me if this is a dumb question, but since I have to create a page under the admin page tree to get SF to work, why can't I add images to this very site's /assets/files/ folder? But I guess the answer does something like because the fields I create on the required php or json file don't really exist in the system and are create at runtime? 1 Link to comment Share on other sites More sharing options...
froot Posted November 21, 2023 Share Posted November 21, 2023 can I generate an InputfieldAsmSelect to select pages from the page-tree? Link to comment Share on other sites More sharing options...
Macrura Posted April 29, 2024 Author Share Posted April 29, 2024 @froot sorry I didn't see your posts. On 9/29/2023 at 8:26 AM, froot said: Please forgive me if this is a dumb question, but since I have to create a page under the admin page tree to get SF to work, why can't I add images to this very site's /assets/files/ folder? But I guess the answer does something like because the fields I create on the required php or json file don't really exist in the system and are create at runtime? Expand If i understand correctly the admin pages use the admin template which is not a configurable template. You could create a settings page under the admin using the ProcessPageEdit process and then using a hook you can get that admin page to use a page in the tree, like "/settings/"; this was an old trick we used to do all the time and suggested by @Jonathan Lahijani. In terms of the general workflow for the settings factory, i just don't attempt to use images on those settings pages, but what I do is use a centralized media library to store site assets such as a logo. The logo is also tagged as such, and is additionally easily findable by the site managers and they can replace it on their own if they need to; this allows me to use all of the features of the regular page editor and images field and not have to hack it for use in Settings Factory. In SF you could create a page select that would allow selection of that media item. 1 Link to comment Share on other sites More sharing options...
froot Posted May 16, 2024 Share Posted May 16, 2024 I'm trying to achieve the following: I already have a selectoptions field with a specific page array. I want to add custom links to that array that I would define as JSON inside another field "menulinks" on this very settings factory page. How can I access the fields value while I'm on the settings page? I understand I would need to save the page first before the value is accessible inside the options field? So how to access the value? It must be stored somewhere… // Assume $fields is your instance of the Fields API in ProcessWire // Fetch the 'menu_allocation' field $menuField = $fields->get('menu_allocation'); // Get the options for the 'menu_allocation' field $menuOptions = $menuField->type->getOptions($menuField); // Create an empty array to store the page arrays for each option $pageArrays = array(); // Loop through each menu option foreach ($menuOptions as $menuOption) { // Convert $menuOption to a string $menuOptionString = (string)$menuOption->title; // Create a selector to find pages with 'menu_allocation' set to the current option $selector = "menu_allocation=$menuOptionString, sort=sort"; // Find pages that match the selector $treePages = $pages->find($selector); // Convert the pages to an array $pageArray = array(); foreach ($treePages as $page) { $pageArray[$page->id] = $page->title; } // Add the page array to the main array $pageArrays[$menuOptionString] = $pageArray; } $inputfields = array( array( 'name' => 'menulinks', 'label' => 'menulinks', 'type' => 'textarea', 'value' => '', 'columnWidth' => 30, ), ); // json_decode the "menulinks" value to an array // merge the resulted array with the pageArrays // Loop through each page array and create 'asmselect' field foreach ($pageArrays as $menuOption => $pageArray) { $inputfields[] = array( 'name' => 'page_select_' . $menuOption, // Unique name based on $menuOption 'label' => 'Select a page for ' . $menuOption, 'type' => 'asmselect', 'description' => 'Select a page from the page tree for ' . $menuOption, 'columnWidth' => 100, 'useLanguages' => false, 'options' => $pageArray, // Use the page array as options for the 'asmselect' ); } return $inputfields; Link to comment Share on other sites More sharing options...
gornycreative Posted Thursday at 02:12 PM Share Posted Thursday at 02:12 PM On 1/31/2023 at 6:28 PM, Macrura said: Perhaps if you don't mind sharing it, it would be great to have a look! - this is somewhat the original intention of the module, to be able to provide all of those types of settings interfaces like people build for WordPress etc.. Expand I totally forgot to do this. Sorry about that. If you are trying to set up something like this, I have uploaded a small zip that gives an example of how a few things could be done. _theme-options-tabs.php - this is my main settings configuration page. You can see I call a function file and then several tabs files. I broke out the tabs into separate folder/configs because it makes it easier for me to stay more organized as I add more features. _theme_fn.php - this is where my various functions live that construct a number of select options: getImageFields() - I use this in other places in my layout to determine where the main images for content types are to be found in a generic way - this way I can pick and choose which image fields I have on which templates and have a central source of truth to determine what order to grab a primary SEO image from. getEntities() - I use this to get a list of possible owners for the site - this setting gets used all over the place to trigger markup variation. getFontFiles() getFontFamilies() getFontSelectOptions() - I use these to look for fonts in a central font share and also look for font's added through either my Chroma backend theme or via RockFrontend, deduplicate families and provide a simplified options layout that include the css path for compilation into LESS elsewhere. If you look at the tab folders with configs, you can see how I call these functions to populate dropdowns. settings.zipFetching info... 1 Link to comment Share on other sites More sharing options...
Macrura Posted yesterday at 10:19 AM Author Share Posted yesterday at 10:19 AM @gornycreative, thank you, very impressive and interesting to see how you set this up. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now