Jump to content


  • Posts

  • Joined

  • Last visited

  • Days Won


Everything posted by elabx

  1. I think @kongondo gives here a super simple example and even refers to it as trivial, haven't tried anything yet tho:
  2. Basically something like this: image: atlassian/default-image:2 definitions: # Copy files and exclude the ones from .gitignore, # which includes logs and custom overrides out of version control. # Run latest migrations if existing. script: &deploy-script rsync --stats --human-readable --recursive --delete-after --no-perms --no-owner --no-group --exclude-from=$BITBUCKET_CLONE_DIR/.gitignore --exclude="bitbucket-pipelines.yml" $BITBUCKET_CLONE_DIR/* $SERVER_USER@$SERVER_ADDRESS:$APP_PATH; ssh $SERVER_USER@$SERVER_ADDRESS "php $APP_PATH/modules/Migrations/bin/migrate run"; pipelines: branches: main: - step: name: awesomewebsite.com script: - SERVER_USER=$USER - SERVER_ADDRESS=$SERVER - APP_PATH=$PATH - *deploy-script dev: - step: name: dev.awesomewebsite.com script: - SERVER_USER=$DEV_USER - SERVER_ADDRESS=$DEV_SERVER - APP_PATH=$DEV_PATH - *deploy-script So it's like a tad bit more fancy FTP upload lol
  3. Well in this scenario I was talking about a particular project that is more "app like". But the rest of sites I manage, which might have specific features regarding template/fields, different templates that are for one specific website/design, I handle them the same way, repo and deployment through pipelines. I'd love to hear about what other things you've tried if you'd be keen on sharing. I've seen some folks move to Statamic/Kirby for this purpose. Thinking about this I've thought a "migration recorder" built on field save hooks, would be neat. Like, you're doing your work on PW thinking about the awesome features you wanna build, building repeaters/matrix, changing file widths, show conditions, all those things we love. Then you go into Setup > Migrations and you find all the work you just did on your repeater field recorded. Just a thought for one part of the whole problem. EDIT: I just read about the YAML thing Craft does, thanks for sharing! 😮
  4. Give a look at this blog post: https://processwire.com/blog/posts/pw-3.0.153/
  5. Hey @Moritz! I use RockMigrations to handle most of the API related stuff along the initial Migrations module, which has a CLI interface letting me run pending migrations per site and keeps the track of it. The sites all share the same features and templates, nothing can be added as a "site specific feature" that involves a "custom pw stuff" in the database, it religiously needs to be in sync. I use bitbucket pipelines for deployments, and it's a very simple script involving rsync and running the Migrations CLI. I do write everything that involves a "new feature" regarding fields on a page, repeater matrix, etc. I'd say once you got it figured out, most of the time i'm copy pasting between migrations and adapting. I'd love to get in sync with some sort of automated testing (end to end with cypress?), but right now it just involves manually testing, and deploying to a few sites to test, fix otherwise and deploy again. I guess this is more of a management issue?? Maybe I am not understanding your full perspective here. No db dumps becase as you mention, it will mess up content. HannahCodes I migrate using the text version export of the hannahcode haha Module updates I guess just upgrading the files?? Haven't got into a deeper issue where something breaks while doing these. I think, up to know, I have just installed new modules. I keep processwire install outside of this equation, I am not sure if this was a wise decision, but it is like that lol One thing that is super important that I haven't though very well is rollbacks. Right now I basically would just run another migration on top, chekout/cherrypick from earlier branch or sth. Though haven't had enough time on this setup to mess up like this and need a rollback or where just doing a migration on top wouldn't work.
  6. I've thought of this a bunch of times! Common settings for the repeater types. Some I normally use are visibility settings, and sometimes dates for ranges to enable/disable.
  7. Something else I've done is dynamically manage the options available for a page reference field depending on where it is in the page tree through a few hooks. So, say each product category has as children two more "parent pages", one for the products, and one for the specific categories of that product page. I won't go into much detail right now as I don't even know if if suits your case.
  8. I'd approach this with either Page fields. Would it matter if the available sizes available for selection in appear on every product-category??
  9. Check the classes that are rendered within the body tag, you should see useful classes there to override css per-role. If you mean tabs/fields within the edit pages screen, there is a lot that can be made through roles and field permissions. https://processwire.com/blog/posts/field-permissions-overrides-and-more-2.6.2/#granular-access-control-with-field-level-permissions This post is old but I bet (without guarantee) that it most likely remains the same or very similar. This Dashboard is super configurable and I bet you can simply wrap the configuration of the panels into some switch/if statements to deliver configurations per role/user.
  10. Not sure if you read my last post and why I asked what I asked but nontheless I think you could try the following code on ready.php. Have in mind, the following function declared in the saved() hook executes after the page is saved, which would be my first approach in getting the gecoded location without doing all the pages in one request . So this approach sort of "throttles" geocoding the address, doing it only when the user adds the address. $wire->addHookAfter('Pages::saved', function(HookEvent $event) { $page = $event->arguments(0); // Skip if not the template we are interested in.. if($page->template != 'customer_project') return; $geo = new \OpenCage\Geocoder\Geocoder('API-KEY'); //This is the field that contains the address in the pages with customer_project template $address = $page->address_field; if ($page->customer_project_address === 1 && $address){ // I guess the first param is the actual address? $address assigned above? $result = $geo->geocode("Another location", ['language' => 'Sweden', 'countrycode' => '+46']); $first = $result['results'][0]; $coordinates = $first['geometry']['lat'] . ',' . $first['geometry']['lng']; //here the field gets saved, have in mind that this is different than saving //the whole page, which would get is into an infinite loop in this scenario $page->setAndSave('my_location_field', $coordinates); } });
  11. Would it work if after one of the following events: User visits page (literally opens up the browser in the page) Page save (whoever saves the address, hits Save in the admin, or the page is saved through the api) The location lat, lng would get added and saved to the page's field through the API?
  12. This does seem like an issue with htaccess not kicking in or mod_rewrite, does writing gibberish on the access throw an error? Cheap trick to see if it works ha! 🤔
  13. Hi!! Try this: $found = $pages->find('template=customer_project'); forach($found as $p){ $p->setAndSave('location',"Hello world" ); } EDIT: Just reading again that you have this in ready.php so this will run on every page load, for every page with custom_project template, not very efficient lol. Like you mention, perhaps a hook after certain action would be better?
  14. Very elucidating!! I'm learning this myself and it's great to confirm/correct some of the assumptions I had. Thanks a bunch for this @MarkE!
  15. More info on this suggestion: https://en.wikipedia.org/wiki/Post/Redirect/Get
  16. If I'm understanding the problem right, maybe the PagesNames class could be useful in this scenario?? https://processwire.com/api/ref/pages-names/unique-page-name/
  17. Mine's still open and bleed once in a while with support emails lol so that's why I've decided to tackle this once and for all. I have a vague memory of this but don't clearly remember why momentjs was introduced. I'll just start without it? x10000000 I understand the issue well here. My guess if that it should work just as a FieldtypeMulti? If anything I appreciate your time to answer my questions! I am a bit nervous cause I know it's no easy feat, but excited to try to bring this to a more stable status. I will try to reuse most of the UI design wise at least to start with something, I think that part could be salvaged and is already a great deal of work? I'm sure it might have some areas improvement but I have used it successfully with a lot of people (when it works :D) that's why I feel it's really worth saving.
  18. Great idea! I always wondered how the meta() feature could useful haha.
  19. Hi! I am trying to build a new version (open source) of the recurring dates module released a few years ago. And I've found myself with a couple doubts. I am building it as a single value Fieldtype module where I want to save the rrule string (to render the UI) but I want to save the actual occurrences of the rule in a second table, so I can use mysql to query the actual dates. Does this make sense? Is there another field around that uses a secondary table to save data? If this is sensible, where should I do it?? sleepValue()? savePageField()? @adrian I think I saw you suffering with the bugs a lot around the support thread haha, so any input on how you would approach the development/refactors of this would be appreciated. Right now on the "big picture" I want to use Alpine.js to redo de Inputfield and looking for advice here on how to do the actual Fieldtype. Also it's the plan to completely rely on rlavin/php-rrule . And this module will only involve the fieldtype/inputfield not the whole rendering modules that came along the original one.
  20. You can use the ImageSizer class, rough example assuming you already have saved the image on disk: $fullpath = "/var/www/images/someimage.jpg"; $options = array('upscaling' => false, 'quality' => 100, 'sharpening' => 'soft'); $imageSizer = new ImageSizer($fullPath, $options); $success = $imageSizer->resize(100, 200);
  21. What type of field is misc_site_meta?? Most get methods will return a "non iterable" object so first() is unlikely to work. Ok it's a repeater, you specifically say so in the title lol my pardon! Try: $homepage->misc_site_meta->get('title=year'); This will get you the first repeater item in the misc_site_meta field where title field equals "year".
  22. Hi! ProcessWire stores all its data in a MySQL database. You don't seem to mention that in your post so I'll give a wild guess that it's a part that might be missing. Is the copy of the project running locally or on a server?
  23. This might be what you're looking for: https://processwire.com/api/ref/inputfield-text-tags/tags-array/ Corrected, this is the link: https://processwire.com/api/ref/inputfield-text-tags/get-tags-list/ You can also get the inputfield from the field like this: https://processwire.com/api/ref/field/get-inputfield/ Something like this might work, haven't tested: $inputfield = $page->getInputfield('tags_field'); $list = $inputfield->getTagsList(true); foreach($list as $item){ // echo checkboxes ? }
  24. I think something like ploi.io or runcloud could work for you. I personally use Runcloud but they appear to be moving slower than ploi "feature wise" although it has worked perfectly for all the sites I manage and their support is fair for the paid price. Both this services clear your goals from 0 to 4 in one way or another. I also think both has some sort of deployment tool integrated with any git repo (which I don't personally use but i think it's there). One "downside" is that ploi doesn't have Apache server configuration they went full nginx though I know there's some crew around here running PW with no issues on nginx. Aside from that, they do seem superior feature-wise. For example, there you can have db only servers, load balancers. The worse part of Runcloud in my opinion is it's per-site backup service which is a service provided by them, Ploi lets you use your own storage (s3 for example). One thing both services have is cloning one "app" into another one, or another server, at least I can confirm this on Runcloud, but seems to exist in ploi too and it's super handful. Another way I do this is through CI services (like Github Actions) and basically doing some shell scripting which is not too bad for all the time saved. In the Github Actions I basically rsync template files/modules and run the migrations module through it's CLI but I rarely push actual content since it's managed by a third party. While on development, I do still use plain old cli mysql import, scp the things or run ngrok to save the hassle of doing previous steps if I just want to quickly demo sth, but tbh it's just lazy on my part I bet it can be easily automated. EDIT: Another trick I do some other times is ssh tunnel a db connection to the actual server. Which is something that moving away from shared hosting makes really simple 🙂 I am also trying to find the time to explore deployment using docker but well, just a plan for when I have some spare time. Check this thread too for other opininons/services:
  • Create New...