Jump to content


  • Posts

  • Joined

  • Last visited

  • Days Won


Everything posted by jploch

  1. I might do that, but I am still not sure what's the best way to implement this. I made changes to the PagesExportImport Module, but I think it would be better to implement this in the core PagesExportImport Class. That would make the feature available to the API and other modules as well. But I am not sure how to do that, because to import the meta data, the pages must be created first, so the code might only work in the module, after the pages are created.
  2. I had a look at it and it wasn't that complicated to implement. Here is a version of the ProcessPagesExportImport module that support export/import of $page->meta(): https://github.com/jploch/ProcessPagesExportImport Would be nice to have this in the core.
  3. I had a look at it and it wasn‘t that complicated to implement. I have now a version of the ProcessPagesExportImport module that support export/import of $page->meta(): https://github.com/jploch/ProcessPagesExportImport would be nice to have this in the core
  4. I am still working on this one. It works great and is quite flexible now. I made a couple of improvements. Now the data to style the items is stored directly on the item with $page->meta(). This way, cloning pages and page reference fields work out of the box. Also there is no need for hidden fields anymore. The style panel now supports adding custom classes and assigning styles to them. These classes can be used globally on all pages (a css class is also a page). The style panel now supports selecting html tags to style tags globally across the whole site. I did a lot of refactoring to make the code cleaner and more efficient. There are still things where I am looking for feedback before releasing an open beta for this module: Sharing blocks and migrating pages I played with the core ProcessPagesExportImport and the migrator module and it seems that it's not exporting the meta() data, which is a bummer. So for now I might not be able to have a migration feature out of the box. Maybe someone else can take a look at this, but it seems to be too much hassle for me now. Importing/exporting the whole database with ProcessDatabaseBackups works as expected though. Also I did develop some block modules that you can install optionally, these will create the needed templates and fields for that block and give you a quick way to start working with PageGrid (without the need to create your own templates or install a site profile), more on that later. (Item pages are based on a block template). Structure of PageGrid items/pages I decided to always store the items under the admin page in a seperate parent, instead of making the parent customisable (like PageTable is doing). So there is a clear separation between pages for your site and item pages. PageGrid then creates a structure looking like this (makes it easy to access the pages): Admin – PageGrid Items – Home items (name: for-1213) – Item Editor – Item XY – Another Page items (name: for-1315) – Item Group – Item XY – Item XY – Item Editor The structure of these pages is an exact representation of the PageGrid items/pages (sorting, child/parent relation, hidden/published). While working with PageGrid via the UI this is not so important, but I think it will make interacting with the item pages via API more flexible and clean. Adding a page to any of the item pages via API or the backend also adds the page to PageGrid. If you delete a page containing a PageGrid field, the items also get deleted. You can also sort via API (or manually under the Admin page) and the changes are reflected for the items as well. The connection is via a name like for-1213, where 1213 is the ID of the page holding the PageGrid field (inspired by repeaters). I like this setup because it gives you a lot of options to access items via API and keeps the pagetree clean. Also it will make it easier to handle migrations for pages containing a PageGrid field in the future (just import/export the page and the item page container). One downside, though, is that the methods of PageTable like $page->pt->add($newpage) or $page->pt->remove($newpage) are no longer working (PageTable is using a PageArray that is saved as the field value). Also this will not work with multiple PagGrid fields on one page (A PageGrid field can however have a page reference field to another page containing a PageGrid field, as well as having nested pages, so I see no benefit of supporting multiple fields). You can add a page to the item parent like this: // Add an PageGrid item via API $itemParent = $pages->get("for-$page->id"); $itemParent->add($newpage) I am not decided if my approach is better or if I should just stick with the PageTable methods (keeping the items stored as PageArray inside the field). Since PageTable can only have one parent that you select in the field settings, all items will than be stored under the same parent, which is a bit messy. Not sure if any of that makes sense to you 🙂 Any feedback is welcome. More info and website is coming soon!
  5. Hi folks, I just tried to export/import some pages with meta() data using the ProcessPagesExportImport module from the core. Unfortunately the data is not exported. Is there a way to migrate pages with meta data to a new pw installation? See the API docs for $page->meta() for more information. Since this is a relatively new addition it might not be possible yet without custom code. Since my new pagebuilder module uses the meta data to save the styling of pages I might develop something myself, just wanted to ask before..
  6. @ryan While working on my pagebuilder module I also figured out that the meta data from $page->meta() is not exported with the page. This is a real bummer, because my page builder is storing all the styling information in the corresponding $page->meta and it would be nice to use this core feature to export that data as well
  7. @ryan Do you have any plans to support the export/import of pages with a PageTable field? Would be nice ! 🙂
  8. although the module works fine, i found an error today when you make a backup of the database. the backup cannot be restored and an error message appears. If I uninstall the module, the backup works fine again. It took me several hours to find that this module is causing the error. I did the backup using the ProcessDatabaseBackups module. Maybe someone else can confirm this?
  9. I noticed that $config->defaultAdminTheme is overwritten in the config file after I install a profile that I exportet. It will allways append $config->defaultAdminTheme = 'AdminThemeUikit'; to the end of the config file overwriting any settings that it imported before that.
  10. @taotoo I use the theme for all my client projects and had no issues so far. This might be a problem with your permissions setup. Is the view link showing with the default uikit theme?
  11. @adrian it still returns the same: '/admin/setup/template/edit : /index.php'
  12. @adrian I added that line to the function and restartet valet, but nothing changed as far as I can tell. I still don't see the field and template infos in the request info panel
  13. it returns: '/index.php' I don't have the file general.php on my system. Maybe it's a Craft CMS thing? Maybe I can update the ProcessWireValetDriver.php file, which I think is doing everithing to make valet and ProcessWire work together. Iam not very exoerienced with valet and php in general, so I have no idea where to start. I got the file from this thread (not sure which version I picked). Here is the code a have in that file, if it helps: <?php class ProcessWireValetDriver extends BasicValetDriver { private $possibleDirectories = [ '', // PW in root, do not remove except you're sure you never use it '/dist', '/public' ]; /** * Determine if the driver serves the request. * * @param string $sitePath * @param string $siteName * @param string $uri * @return bool */ public function serves($sitePath, $siteName, $uri) { foreach ($this->possibleDirectories as $dir) { if(is_dir("{$sitePath}{$dir}/wire")) return true; } return false; } public function isStaticFile($sitePath, $siteName, $uri) { foreach ($this->possibleDirectories as $dir) { if(is_file($staticFilePath = "{$sitePath}{$dir}{$uri}")) return $staticFilePath; } return false; } /** * Get the fully resolved path to the application's front controller. * * @param string $sitePath * @param string $siteName * @param string $uri * @return string */ public function frontControllerPath($sitePath, $siteName, $uri) { $_SERVER['SERVER_NAME'] = $_SERVER['HTTP_HOST']; $_SERVER['SCRIPT_NAME'] = '/index.php'; $_GET['it'] = $uri; if ($uri === '') { $uri = '/'; } foreach ($this->possibleDirectories as $dir) { if(!file_exists($indexPath = "{$sitePath}{$dir}/index.php")) continue; // $_SERVER['REQUEST_URI'] = substr(str_replace($dir, '', $_SERVER['REQUEST_URI']), 10); $_SERVER['SCRIPT_FILENAME'] = $indexPath; if (file_exists($indexPath = "{$sitePath}{$dir}/install.php")) { return $indexPath; } return parent::frontControllerPath( "{$sitePath}{$dir}", $siteName, $uri ); } } }
  14. Thanks again for looking into this. Here is the dump return (local enviroment): '/admin/setup/template/edit : /index.php'
  15. @adrian Thx! That was fast! The error is gone now. However I still don't see the field and template infos in the request info panel on my local installation. Here is a screenshot of my local request info panel (Viewing the template settings page for template home) And here is a screenshot from my shared hosting, both have the new tracy version installed (Viewing the template settings page for template home) Both have these settings for the info request panel:
  16. I also have issues with tracy since I switched to laravel valet for my local development (Mac OSX Monterey). The panel is loading but I can not see field and template infos in the request info panel. Also I get an error when visiting a template settings page in the admin. The module works fine with the same setup (Site Export) on my shared hosting server. I access my site via http (http://projectname.test). Iam using Tracy version 4.23.25. Here is the template error: ErrorException: Undefined variable: template in /Users/jploch/Sites/PageGrid/dist/site/assets/cache/FileCompiler/site/modules/TracyDebugger/panels/RequestInfoPanel.php:572 Stack trace: #0 /Users/jploch/Sites/PageGrid/dist/site/assets/cache/FileCompiler/site/modules/TracyDebugger/panels/RequestInfoPanel.php(572): Tracy\Bar->Tracy\{closure}(8, 'Undefined varia...', '/Users/jploch/S...', 572, Array) #1 /Users/jploch/Sites/PageGrid/dist/site/assets/cache/FileCompiler/site/modules/TracyDebugger/tracy-2.9.x/src/Tracy/Bar/Bar.php(141): RequestInfoPanel->getPanel() #2 /Users/jploch/Sites/PageGrid/dist/site/assets/cache/FileCompiler/site/modules/TracyDebugger/tracy-2.9.x/src/Tracy/Bar/Bar.php(113): Tracy\Bar->renderPanels('') #3 /Users/jploch/Sites/PageGrid/dist/site/assets/cache/FileCompiler/site/modules/TracyDebugger/tracy-2.9.x/src/Tracy/Bar/Bar.php(87): Tracy\Bar->renderPartial('main') #4 /Users/jploch/Sites/PageGrid/dist/site/modules/TracyDebugger/tracy-2.9.x/src/Tracy/Debugger/DevelopmentStrategy.php(138): Tracy\Bar->render(Object(Tracy\DeferredContent)) #5 /Users/jploch/Sites/PageGrid/dist/site/assets/cache/FileCompiler/site/modules/TracyDebugger/tracy-2.9.x/src/Tracy/Debugger/Debugger.php(315): Tracy\DevelopmentStrategy->renderBar() #6 [internal function]: Tracy\Debugger::shutdownHandler() #7 {main} I already tried this solution from the linked post above (changing the valet driver), with no success.
  17. @monollonom Thank you! Well what can I say. I swear I tried this and it was not working. I gave it another try and after uninstalling and reinstalling the module it suddenly worked. Sorry! Will read the docs more carefully before I post next time. At least my code may help someone. public function ___upgrade($fromVersion, $toVersion) { $this->createBlock(); }
  18. Hey folks. Iam working on a module that creates some templates and fields. The module creates these on install and deletes them on uninstall, works great. Now Iam looking for a way to run the create function when the module is updated, but It's not doing anything. I changed the version number and hit refreh on the module manager and a message indicated the update, but my function is not executed. Not sure if Iam hooking the right function here or if there is an __update() function I can use? Here is my code so far: <?php namespace ProcessWire; class BlockEditor extends WireData implements Module { public static function getModuleInfo() { return [ 'title' => 'Editor for PageGrid', 'summary' => 'Installs Template and Fields for a PageGrid Block', 'author' => 'Jan Ploch', 'icon' => 'font', 'autoload' => 'template=admin', 'version' => 1 ]; } public function getBlockName() { return array( 'name' => 'pg_editor', 'label' => 'Editor', ); } //function to create block public function createBlock() { $this->message("Create Block"); $this->log->save("PageGridBlock", "Create Block"); $fs = wire('fields'); $t = wire('templates'); $blockName = $this->getBlockName()['name']; $blockLabel = $this->getBlockName()['label']; if (!$fs->get($blockName)) { $f = new Field; $f->type = $this->modules->get("FieldtypeTextarea"); $f->name = $blockName; $f->label = $this->_($blockLabel); $f->tags = 'pgrid'; $f->save(); } if (!$t->get($blockName)) { $f = $fs->get($blockName); $titleF = $fs->get('title'); // fieldgroup for template $fg = new Fieldgroup(); $fg->name = $blockName; $fg->add($titleF); $fg->add($f); $fg->save(); $t = new Template(); $t->name = $blockName; $t->fieldgroup = $fg; $t->icon = $this->getModuleInfo()['icon']; $t->save(); } // Copy block files $copyFrom = $this->config->paths->BlockEditor . "blocks/"; $copyTo = $this->config->paths->templates . "blocks/"; $this->files->copy($copyFrom, $copyTo); } //function to remove block public function removeBlock() { $this->message("Remove Block"); $blockName = $this->getBlockName()['name']; $t = $this->templates->get($blockName); $fg = $this->fieldgroups->get($blockName); $f = $this->fields->get($blockName); if ($t && $f && $t->getNumPages() > 0 && $f->getNumPages() > 0) { throw new WireException("Can't uninstall because template or fields been used by some pages."); } else { if ($t) { wire('templates')->delete($t); } if ($fg) { wire('fieldgroups')->delete($fg); } if ($f) { wire('fields')->delete($f); } } } public function init() { // trigger on module update $this->addHookAfter('Process::upgrade', function (HookEvent $event) { bd('update'); $this->createBlock(); }); } public function ___install() { $this->createBlock(); } public function ___uninstall() { $this->removeBlock(); } }
  19. if you want to use this theme together with the Tracy debugger module. Tracy has an option now to change the position of the bar to the left side:
  20. Iam sorry to bump an old thread, but Iam currently working on a comercial module and looking for ways to make the update process as easy as possible. When I try fgb13 solution above I get this error after clicking on the "check for updates" link on my module settings page: ProcessModule: Error decoding JSON from web service My url is pointing to a zip file with my module files. Is there anything else, that needs to be done? EDIT: Ok I got it working. I had to link to a json file instead. Here is an example of how that file might look.
  21. @horst THX for the quick fix! Unfortunately my client already made the change to PHP 7.4. and I do not have a php 8 environment to test this at the moment. I will report back once I setup a local test environment.
  22. Hi! This is a really useful module. I use it to combine some graphics with the watermark option. However today a host of my client updated to PHP 8 und I got a fatal error: Exception: Cannot load the MemoryImage! After donwgrading to PHP 7.4. everything worked again. The host told the client they will switch to PHP 8 next year and only offer paid support for older versions, so it would be nice if I can continue to use this module. Are there any plans to support PHP 8 in the future?
  23. Hey! Today I discovered a strange behaviour with a fieldtype module Iam currently developing. I have a function that updates the config of the corresponding inputfield module, this functon is called via ajax to update one of the config options (a textarea) with some data. The strange thing is that sometimes it works and then sometimes it saves the new value but deletes all the other config options. Any Ideas why this could be happening? Here is the code that saves the inputfield config, this code is inside a process module and gets called via ajax: $settingsName = $this->sanitizer->text( $_POST['settingsName'] ); $settingsValue = $_POST['settingsValue']; if ( !empty( $settingsName ) && !empty( $settingsValue ) ) { $f = $this->fields->get( "pgrid" ); $f->set( $settingsName, $settingsValue ); $f->save(); return; } (testet on lates PW master Version 3.0.184)
  24. Thanks Adrian! I try to remove those checks and do some testing. Will report back soon.
  25. After some more tests with PageTable, I found out that migrator is not exporting/importing pages under admin. In my use case I have PageTable configured to save all item/pages in a container page under admin. For example admin–>pt-items. However with this setup migrator only exports the main page where the PageTable lives without the items. Placing the PageTable items under admin is a common thing, if you do not want editors to mess with them and keep your page tree clean. I think people also use this approach with PageTableExtended. So it would be nice if migrator would export PageTable items that live under admin or a diffrent parent than the containing page. Since PageTable has a field that saves the IDs of the item pages, that could be used to identify the items. I understand if this is out of scope for migrator. If so I might look into building my own solution.
  • Create New...