-
Posts
6,312 -
Joined
-
Last visited
-
Days Won
318
Everything posted by bernhard
-
This is what I'm doing with RockMatrix: I guess that's option 3 ? Not perfect, but the best option I have so far... While I see the benefits of option 1 I can't see any client in the world be able to use it. And even if you where a developer it would need very good understanding of the setup or css framework that you use to understand exactly what you need to do, where you need to click, which block you need to indent and where etc...
-
RockMigrations1 - Easy migrations from dev/staging to live server
bernhard replied to bernhard's topic in Modules/Plugins
v0.0.75 adds a new method addLanguage() that makes it super easy to add a new language to your pw site: // get german translations for default language $rm->setTranslationsToLanguage("https://github.com/jmartsch/pw-lang-de/archive/refs/heads/main.zip"); // add english as second language (including language field tabs and page names support) $rm->addLanguage("en", "Englisch"); https://github.com/BernhardBaumrock/RockMigrations/commit/3e52805b9f6f3582f63826d179c753f1ad6c0750 I had a quite hard time to get this working because setting the "name" of the root page was not as easy as expected. I had to hack it via custom sql: https://github.com/BernhardBaumrock/RockMigrations/blob/3e52805b9f6f3582f63826d179c753f1ad6c0750/RockMigrations.module.php#L2235-L2242 If anybody finds a better way of doing this please let me know ? -
RockMigrations1 - Easy migrations from dev/staging to live server
bernhard replied to bernhard's topic in Modules/Plugins
Thx, fixed in v0.0.73 -
RockMigrations1 - Easy migrations from dev/staging to live server
bernhard replied to bernhard's topic in Modules/Plugins
When I started with RockMigrations I had a setup similar to other migration modules where every migration was its own file and had an upgrade() and downgrade() method. I also had methods to check whether a migration should run or not (version compare). But that was a pain to work with, so over time the declarative syntax won. I agree that sometimes it would be nice to have the option to run migrations only for some versions of the project, but I have not had a good idea how to achieve that yet... -
RockMigrations1 - Easy migrations from dev/staging to live server
bernhard replied to bernhard's topic in Modules/Plugins
Adding data via migrations is the most straightforward thing, but removing or renaming is a little more tricky, as you realized ? Usually all methods are built in a way that they can run as often as you want. That means you can just run $rm->renameField(...) as often as you want: https://github.com/BernhardBaumrock/RockMigrations/blob/dc9dba1b050469ea085af9dca1201746e2422960/RockMigrations.module.php#L942-L944 I know that adds a little overhead and I've heard from @dotnetic that some of his migrations needed around 20 seconds to finish. On all of my setups (and I'm using RM all the time, everywhere, extensively) site-wide migrations fired via $rm->fireOnRefresh(...) take at most around 2 seconds to finish. If you really want to avoid that, you can always do custom logic via PHP's if/else... Of course that does not work with declarative syntax, but that's no problem in my opinion. The declarative syntax is easier to use and easier to read, but it has limitations regarding the execution of things by design. I'm not sure. I've evaluated it more than 2 years ago and never ever used it again. It was simply useless for my workflows. I've just had a glance in the core and it does not seem to be very helpful for RM. I've just addes support for your request and added an example to the readme: $rm->migrate([ // fields to create 'fields' => [ 'ready_text' => [ 'type' => 'textarea', 'tags' => 'ReadyDemo', ], 'context_example' => [ 'type' => 'text', 'label' => 'Global field label', ], ], // templates to create 'templates' => [ 'ready_blog' => [ 'tags' => 'ReadyDemo', 'fields' => [ 'title', 'context_example' => [ 'label' => 'Field label on ready_blog template', ], ], ], Repeaters $rm->migrate([ 'fields' => [ 'foo_field' => [...], 'bar_field' => [...], 'my_repeater_field' => [ 'type' => 'repeater', 'repeaterFields' => [ // you can set field data in repeater context like this: 'title' => ['required'=>0], 'foo_field' => ['columnWidth'=>50], 'bar_field'=> ['columnWidth'=>50], ], ], ], ]); -
Determining the context a page is being created in [solved]
bernhard replied to FireWire's topic in API & Templates
Sounds like you can simply set a flag at runtime: <?php // your script that creates the json page $page = new Page(); ... $page->createdViaApi = true; $page->save(); Then your hook should be able to catch that flag: <?php $wire->addHookAfter("Pages::saveReady", function($event) { $page = $event->arguments(0); if($page->createdViaApi) { // check and throw exception } else { // check and show error to user } }); -
Thx @teppo It's option a) custom SQL queries ? I can't share details here but it's quite complex ? I mean... it's easy to use but in the background the module creates a quite complex sql query based on indices that I define for the search.
-
Copy predefined fields to child-page per category
bernhard replied to pixelschiff.net's topic in API & Templates
We also have a dynamic options module -
RockMigrations1 - Easy migrations from dev/staging to live server
bernhard replied to bernhard's topic in Modules/Plugins
At the moment not, but if you think that would be worth to have you could add that here and create a PR: https://github.com/BernhardBaumrock/RockMigrations/blob/dc9dba1b050469ea085af9dca1201746e2422960/RockMigrations.module.php#L984-L990 -
Very nice, thx, I'll try that asap on my new website ? Does it translate all fields after save or only ones that changed during page edit? Sorry if that was already mentioned - I didn't find that information.
-
Copy predefined fields to child-page per category
bernhard replied to pixelschiff.net's topic in API & Templates
The easiest solution would probably be to add all fields to your template and then just hide the ones you don't need via hook: <?php $wire->addHookAfter("ProcessPageEdit::buildForm", function(HookEvent $event) { $page = $event->object->getPage(); $form = $event->return; if(...) $form->remove('yourfield'); }); -
Add more fields to "Add Page" for particular page type?
bernhard replied to Goca's topic in API & Templates
Sure: https://processwire.com/blog/posts/processwire-2.5-changelog/#adding-pages -
RockMigrations1 - Easy migrations from dev/staging to live server
bernhard replied to bernhard's topic in Modules/Plugins
$rm->setFieldData("yourfield", [...], $rm->getRepeaterTemplate("yourfield")); -
Any screenshots to get a quick impression? ?
-
Thx @Stefanowitsch It's a module based on the core repeater fieldtype that manages the necessary templates and fields for content blocks via RockMigrations. Every block is a custom ProcessWire page having a custom template. The matrix field: Each block itself looks something like this: ...which makes it extremely easy to work with on the backend and to organize code well. That means each content block has its own file that defines all the necessary pieces, eg which icon and description to show for the button, which label to use on the sortable matrix field and which code to use for output rendering: Only drawback is that it does not support nesting yet - but I'm not sure if that is really a drawback because I don't think the average user would understand how to use such a feature...
-
I've had to deal with this issue today and I tried my fix from last year and unfortunately got wrong results as well ? I'll send you the image via PM @horst
-
https://www.kaumberg.gv.at/ Hello everybody! Today I want to share a project that I've been working on for a year or so: The new website for municipal Kaumberg - a beautiful village near Vienna. To be honest, this project was way more work than I initially expected. The site has tons of content and the client came with lots of good ideas during the process of building this site. For example after we launched the site several organisations of the village realized that the system works great and is easy to use, so they wanted their own section with their own color scheme... Right now the system is maintained by several user accounts that populate content to the site. Some of them only in the news-section, others are allowed to publish to the sub-sites (eg for the fire department). Recently we won the 2nd price out of 190 cities in lower austria - where Kaumberg was by far the smallest one also having the smallest budget of the top rated cities! ### NOTE ### This system was built with scalability in mind. If you know any other municipals (preferable in a german speaking country) that could possibly need a new website using my setup write me a PM. If you are a marketing guru and know how we can sell this product to 100s of municipals, let me know. I know how to do that from the technical point of view ? ### HIGHLIGHTS ### CONTENT Custom multi-level menu for managing loads of content pages that also works well with keyboard navigation ? --- EVENT MANAGEMENT Events are managed via the PW backend and presented as calendar on the website plus can be downloaded as PDF calendar in A3 format for printing: --- CONTENT BLOCKS I've developed a new (private) module called RockMatrix for versatile, easy and fool-proof content creation for this project. This setup ensures that even non-tech-savvy users can create content that looks nice and works on all devices from desktop to mobile: --- SITE SEARCH Another new module that was developed for this project is RockSearch. I hate site searches that do work on the first sight but do not on the second. For example if they show older results on top of newer ones. Or if they do not index content that is not stored within a regular text field but for example as image description. On the other hand I did not want to use ElasticSearch because it seemed to be overhead to send data to another service that is already stored in the database of my PW installation... RockSearch shows results based on different weighing mechanisms, for exampe a search for the garbage collection schedule first shows results that are nearer to the current date than others (both future and past). That means that a date two days in the future will be shown above one that is 10 days in the past. Also results get different score based on where the term was found - matches in the site title get higher scores than matches in the body or in image descriptions or the like. Each content block is a RockMatrix block that has a render() method to define the output on the website and - for RockSearch - has a method called "searchIndex()" that defines the content that is written to the search index that is queried for every search request: This setup makes it super easy to add new content elements and to add them to the search index ? --- SUB-SITES The client can create sub-sites for different organisations of the village having custom color schemes and managing user access: News can be tagged to show up on different areas of the website: --- OTHER The site uses no cookies and can therefore be used without an annoying cookie banner. Page hit statistics are gathered by PageHitCounter and shown by RockHitCounter Some other little features are short-links for social media (eg https://www.kaumberg.gv.at/goto-1027 ) or the possibility for creating custom subdomains for sub-sites like http://araburg.kaumberg.at/ I'm quite sure I forgot lots of great stuff, but I hope you enjoyed reading this article nevertheless ? Looking forward to your feedback!
- 10 replies
-
- 26
-
I guess because you are in a module you have output formatting OFF which means that $page->image is an array of images and not a single PageImage object. Using $page->image->first()->size should work. PS: To make everything clear and reduce chances for errors you can be more verbose and use $page->getUnformatted('image')->first()... PPS: Better check if an image was uploaded before using ->size(...) $img = $page->getUnformatted('image'); if($img AND $img->count()) { $img = $img->first(); $img->size(...)->... }
-
I can just say that I'm still having this issue as well...
-
@dotnetic does your module still work? Or do we have any better options in late 2021? ?