Jump to content

gornycreative

Members
  • Posts

    385
  • Joined

  • Last visited

  • Days Won

    5

Everything posted by gornycreative

  1. Looking into it more, I have come to the conclusion that the Search page uses the admin template and as a result falls outside the public facing page class framework. Even though the output from the controller/view is a ProcessWire/Page class, there is no way to extend the pageclass because it is the Process that dominates the function of the page. If I wanted to modify the Search workflow I could hook into it, but because I actually want to grab url segments and run some query magic to convert them into a complex query to pass to search, I think I will need to set up a unique page and pageclass to do that. Hopefully someone with more knowledge of the admin side can chime in.
  2. I noticed the search template and search page do not seem to be alterable by defining a custom page class. If I try creating a page class file where class SearchPage extends Page { it does not appear to effect the Search page class at all - the page still appears as ProcessWire/Page and none of the public functions I define can be used. Is this a feature of having a page that uses a Process or is it because it is a system file, or is there a different class it should extend?
  3. Me neither! I thought I'd play around with it. Just over here breaking stuff...
  4. Hi! EDIT Sorry this is on v 4.25.5 Running a bardump on the front-end for a variable (in this case, I'm passing a latte_vars array for verification) throws a type error: That $object_or_class array is:
  5. Hello, I was originally going to include this as part of my forthcoming AdminStyleChroma module but decided to roll it out as its own module. https://github.com/solonmedia/ImageColorThief Please check out the readme for a deeper explanation - but the short version here for now: This module adds two new methods to the Pageimage class, allowing you to extract the main dominant color or a palette of prevalent colors from an image. You can use the entire image to evaluate color dominance, or you can use a select swatch from the image based on inset rectangles from the edges, blocks at each corner, or a swatch centered on the focus point if you choose to use it. You can also select the granularity of the quantization to get more accurate color results. This is not an eyedropper algorithm - the colors are close approximates. Great if you have color schemes you'd like to coordinate with the headliner or seasonal images, or if you'd like to be able to sort a gallery of images by dominant color, etc. Looks real nice, for example if you are running a ken burns style image fade background and the images are sorted by a channel, etc. How to sort them? Ugh that's something I haven't tackled - yet: https://www.alanzucconi.com/2015/09/30/colour-sorting/ It works on JPG, GIF, PNG and WEBP images. It outputs RGB, HEX, RGB Integer, raw Array with R, G, B elements or an object. Once I've got myself registered and whatnot I'll submit it to the Modules Directory. Installs from zip for now: https://github.com/solonmedia/ImageColorThief/archive/refs/heads/main.zip I'd consider it Beta - the underlying libraries are pretty stable but I'd like to run a few more tests on input. Let me know if you have any questions/thoughts.
  6. Okay I think I found a way - it is circuitous but it seems to work, so I will post it for posterity in case anyone else is trying to mess around with saving similar data in this way... //This is for use INSIDE a method being added via Pageimage::addHookMethod but Pagefile should work in a similar manner //Grab the event object. $f_pageImage = $event->object; //Grab the page the event object lives on. $page = $f_pageImage->page; //Grab the unformatted version of the pageimages array the event object lives in from the field $u_Images = $page->getUnformatted($f_pageImage->field->name); //Grab the file inside the unformatted field content array that has the same filename as the original file objects filename $pageImage = $u_Images->getFile($f_pageImage->basename);
  7. I am close to releasing a module that adds hook methods to Pageimage that will calculate the main color and/or a palette of dominant colors in an image. I've been looking at different options to store/cache this value based on a comparison of the options array used to grab the first calculation, because with some image sizes and precision factors and the number of images the calculation lags more than you would want on a front-facing site. If the data exisits, use it unless the options array passed along is different than the one stored - in which case recalculate. My initial thought was to store them in the filedata array for the given file, and I can get/pull the item but I cannot save the Pageimage filedata within the hook because the hook runs regardless of whether or not you get the initial images in a formatted or unformatted state. I can grab the data and save it outside the hook method like so: $page = $this->wire->pages->get('name=about'); $images = $page->getUnformatted('images'); foreach($images as $image) { $palette = $image->palette(); $maincolor = $image->maincolor(); $image->save(); } But this makes the process more cumbersome for developers. I'd rather have the hook method somehow be able to grab the unformatted version of the Pageimage from the Pageimages returned by the 'images' field, merge the filedata colors into the filedata array and save it. The problem is I can't see how to query an individual image/file within that Pageimages/Pagefiles array.
  8. I believe what you are looking for is ImportExternalImages - which was designed to allow a user to cut and paste a blog article from another platform like Blogger into a specified text area and then have PW bring in the assets from the URLs that were pasted into a field you set up in config. https://processwire.com/modules/import-external-images/
  9. I tried turning on tags for an image field using the following config: 'detailed_images' => [ 'label' => 'Detailed Images', 'flags' => 0, 'type' => 'FieldtypeImage', 'icon' => 'picture-o', 'fileSchema' => 271, 'maxFiles' => 0, 'textformatters' => [ 0 => 'TextformatterEntities', ], 'extensions' => 'gif jpg jpeg png', 'outputFormat' => 0, 'descriptionRows' => 5, 'useTags' => 1, 'gridMode' => 'left', 'focusMode' => 'zoom', 'clientQuality' => 90, 'inputfieldClass' => 'InputfieldImage', 'unzip' => 1, 'tags' => 'content_components', 'collapsed' => 0, 'columnWidth' => 100, ], But when I try to edit a page that has the field in the template I get a SQL error: 'field_detailed_image.tags' column not found in 'field_list'. I tried looking deeper into the methods and thought perhaps calling getDatabaseSchema would call the private updateDatabaseSchema but it seems like that doesn't work. I have turned off useTags in the meantime but I'm guessing this affects any fieldtype that extends fieldtypeFile.
  10. I'm afraid I have listened to this loop way too much since I discovered their long-form channel.
  11. Exactly why I asked. And there is a potential solution actually and I found it and started working on some things and forgot to come back to this. The getTableData() function for fields seems to pull just the configured settings in the database table. getExportData actually uses the data from the getTableData call and merges it. It's in wire/core/Field.php
  12. Frames reminded me a lot of Pinegrow - https://pinegrow.com/ - which has some pretty handy shortcuts in the WP version for breaking out flat HTML designs into loop and block files. Once Yootheme Pro started incorporating real-time previews of custom fields and post/page types it finally started catching up to the flexibility and convenience of certain types of PW builds. I am still finding it faster to work in PW, even though I have had a lot more experience with WP.
  13. Never mind. The simplest way to do this is include $rm->watch methods in ready.php that cover the subset I want to pay more immediate attention to and then run migrate those watched files there: $rm = $this->wire->modules->get('RockMigrations'); $rm->watch($wire->config->paths->site.'/migrations',2); $rm->watch($wire->config->paths->site.'/migrations/matrixtypes',1); bd($rm->getChangedFiles()); // Just to check on things. $rm->migrateWatchFiles();
  14. Say I define in my migrate.php: $rm = $this->wire->modules->get('RockMigrations'); $rm->watch($this->wire->config->paths->site.'migrations',3); $rm->watch($this->wire->config->paths->site.'migrations/matrixtypes',1); Suppose I make a change/save/touch this file as /site/migrations/matrixtypes/meta_zone_1.php: <?php namespace ProcessWire; $rm = $this->wire->modules->get('RockMigrations'); $rm->setMatrixItems('meta_zone_1', [ 'profile_image_block' => [ 'label' => 'Author > Profile Image Block', 'head' => '{matrix_type}', 'sort' => 1, 'fields' => [ 'profile_image_block_layout' => [ 'columnWidth' => 50, ], 'profile_image_block_bio' => [ 'columnWidth' => 50, ], ], ], ]); I've brought in the RepeaterMatrix functions from v1 and added the filetype test to createField - let's assume that. Manually triggered these work. When I run $rm->getChangedFiles() I can see the saved file in the list. A change was detected. If I run $rm->migrateWatchFiles(); the file is rendered and the repeatermatrix item is added. I need to run that method, however, in say Tracy console for the changed files to be seen and migrated. However, when I make changes to watched modules and pageclasses that use MagicPage the migration methods automatically run the next time I load an admin page after saving my changes. How do I get that behavior with watched php files that aren't magicpages or in a module? I can see that ready() in the module contains migrateWatchFiles() - I'm guessing it should be firing? If I add bd($this->getChangedFiles()); ahead of this, it always returns an empty array even though when I run the same method in Tracy it detects changes as I save different files.
  15. I don't know why, but I'm not able to get watched files to trigger. They appear in the watchlist when I run a dump. There are rockmigrations methods in the files. I've set the files to force = true in the watch method in migrate.php. I'm at my wits end. migrate.php triggers on change. Page classes trigger on change. I can't get a single watchfile to trigger. Is there a format to watchfiles that I am missing? Edit: The reason I am running into this now is because I had been keeping field migrate definitions and matrixtype definition methods all on one file but that is starting to get hefty and so I wanted to break out the matrix definition types for various repeatermatrix fields into separate files that would only trigger when a new type was added.
  16. I tried moving the error checking portion that tests for admin and processes form input to the ready() and left the hook definitions in init() and it seemed to work fine as written.
  17. If I do a bd in Tracy: /** * Initialize the module * */ public function init() { $input = $this->wire()->input; // $isAdmin = $this->wire()->page->template->name === 'admin'; bd($this->wire()->page); //Should be the same bd($this->wire->page); //But Just in case I get this: Not even a NullPage object which would at least be something. I found a similar method in a thread from years ago where the limitations of init() were also mentioned. I can't recall if that's the first place I'd seen - it - perhaps in the core code itself? From wire/config.php - I think this is where I first saw hints that anything done in init() doesn't know what page exists. But this doesn't say explicitly that you couldn't *get* the page while in the init context, just that the API var isn't instantiated yet. I'm wondering if bumping it to the ready() state would be an option? The thread I linked never really came to a satisfying conclusion - but I'd also like to know if there is a definitive best practice for how to do this. @horst @Robin S ?
  18. Hey there, I'm trying to track down some PHP warnings, and one comes from this module. I understand you are trying to do some error checking in the configuration in the init() function, but unless I'm totally off on this there is no page context for the init() function in modules. I get two warnings on line 68 because template is run on null and name is run on null.. $this->wire->page in the init() method is null because as far as I understand when the init() method is run there is no page actually loaded yet. As a result $isAdmin is never true and that entire module config test block never loads? The hooks are outside the block - so no problems there, but I'm guessing that clearing variations from the module config doesn't work.
  19. What is the best way to get an array of the default settings for a given fieldtype, and are these defined at the core module layer or a class layer or somewhere else? This seems to be where I should go but I've had problems figuring out exactly how to call it abstractly: https://processwire.com/api/ref/fieldtype/get-config-array/ I'm not talking about the configuration for a fieldtype instance, I mean the config of the class.
  20. When you have a Page Reference inputfield, there are two different template options settings: With the standard migrate() config array, the template_id setting gets processed fine if you use a template name instead of the template_id - the green checkmark. The template_ids setting does not get processed if you use template names. Nothing appears. Adding the processing block I wrote above allows template names to be used in that template_ids setting.
  21. Sorry I'm working in @gebeers RepeaterMatrix fork right now, but if you could add around 3200 in RockMigrations.module.php: (This is below the $key === "template_id" conditional test block.) if ($key === "template_ids") { foreach($val as $sub => $tpl_name) { if (is_string($tpl_name) and $tpl_name !== '') { $tpl = $this->getTemplate($tpl_name); if (!$tpl) throw new WireException("Invalid template_id"); $val[$sub] = $tpl->id; } $data[$key] = $val; continue; // early exit } } This would allow the 'Selectable Pages > Additional Templates' setting on Page Reference fields to migrate the 'template_ids' setting properly with template name references into of raw ids in a similar manner to the template_id setting conversion.
  22. Okay. I'm playing around a little bit with the getCode functions to pull names instead of IDs for certain things and looking at the repeatermatrix situation a little more but I will also look at the tab add situation after.
  23. I'm looking at the code for wrapFields() - is this only for Fieldset and not FieldsetTab? If you are using custom tabs is adding a FieldsetTabOpen field type still recommended and then $rm->addFieldToTemplate('fieldname', 'content-page' , 'tab', 'tab_END'); still the best way to do it?
×
×
  • Create New...