Jump to content

Recently Updated Topics

Showing topics posted in for the last 7 days.

This stream auto-updates     

  1. Today
  2. I'm at the end of my rope! I've been trying to use a 3rd party API that requires authorization. I've tried a zillion different ways in both cURL and wireHTTP. cURL always tells me the signature is wrong. wireHTTP returns 401 unauthorized. Here's the brief documentation for authorization with the API: https://integrate.spektrix.com/docs/authentication Here's the latest version of my wireHTTP code: $date = date(DATE_RFC1123); $string = "GET\n/sidwilliams/api/v3/customers/I-KS22-363P/\n$date"; $string = utf8_encode($string); $key = base64_decode('XXXX'); $signature = base64_encode(hash_hmac('sha1', $string, $key)); $http = new WireHttp(); $http->setHeader('Host', 'system.spektrix.com'); $http->setHeader('Date', $date); $http->setHeader('Authorization', 'SpektrixAPI3 website:' . $signature); $response = $http->get('https://system.spektrix.com/sidwilliams/api/v3/customers/I-KS22-363P/'); if($response === false) { echo $http->getError(); }else{ echo $response; } If anyone is interested in seeing my cURL, I can post that too. Thanks!
  3. Hello community, I'm using https://processwire.com/modules/rest-api/ to define some REST API endpoints for my ProcessWire. One of these endpoints receives an ID in the path via /api/foo/:id . I search for the page using $pages->get() and can confirm that it's found. The tricky part is now that when I do $my_page->trash() or $pages->trash($my_page) I end up with the following error: "Attempt to read property "id" on null. File: [...]\wire\core\PagesEditor.php:296" Which seems to be the case because ProcessWire checks with $this->wire("page")->id if the current page is the one I try to trash/delete. Understandably there is no current page when this is not a template file. So how could one proceed to trash/delete a page via REST API if the aforementioned ProcessWire APIs won't work? Best regards Tobias
  4. Hi @shadowkyogre - looks like you would need that logic, but you'd also need to add the TFA field to the login form. Unfortunately I don't have time to look into this at the moment, but if you can get it working and provide a PR, I'd be grateful.
  5. Hi, I use a saveReady Hook and want to set values of the name field according to values from other fields. But only the name field of the default language is updated, regardless of the language the user is in. When saving via API scripts, the result is the same as when saving interactive via page editor. My code is as follows: $this->pages->addHookAfter('saveReady', function($event) { $p = $event->arguments[0]; $lang_DE = $event->wire->languages->get(1016); $lang_EN = $event->wire->languages->get(1018); $newName_DE = 'ein-generischer-neuer-name'; $newName_EN = 'a-genric-new-name'; $p->setLanguageValue($lang_DE, 'name', $newName_DE); $p->setLanguageValue($lang_EN, 'name', $newName_EN); } How can I set (andSave) the other language name too in a saveReady Hook? Or do I need to use another hook for that?
  6. Hi @bernhard. Prompted by your comments here , I decided to give this module a go as it looks very useful. One thing I find rather confusing is that you seem to have changed the suggested methodology and it's not entirely clear to me what is now the suggested best practice for using the module. From what I can see, you are suggesting that users construct their own module (along the lines of your example). Installing this will then run the migration and uninstalling it will do a downgrade. For further migrations, it seems that you are suggesting just adding to this module, not creating a new module. Your previous approach seems to have been more version-based. I am trying to understand how that works in practice. I currently have 2 migrations that I want to carry out. The dev system reflects the end state of both. I want to do it in 2 stages so that I can throroughly test the first migration before applying the second (although I think there is no dependency, it is better to do them in the same order as on the dev system). My plan is therefore to create the first migration module, back up the dev database, load the live database to the dev system, install the migration module to this, then test. If that is OK, then, if I understand correctly, I should amend the migration module to include the second migration and refresh the modules to run it. I would then test again. Now, what if there is a problem with this second migration and I want to reverse it? Uninstalling the module would presumably undo both migrations (unless I change the uninstall method to be only partial, which seems inconsistent). Sure, in the dev system, I could just revert to a backup, but that would not be a solution if the problems happened in the live environment as (unknown) data will also have been updated - in that case I would need to just be able to reverse the last migration. So should I put the second migration in a separate module? In which case, this starts to look more like your initial approach (except that the use of the migrate() method allows for a more declarative style). Am I clear in explaining my confusion? If so, can you de-confuse me? By way of background, here is my first migration plan (as a set of human instructions), to give you an idea about what I am trying to do: 1. Add new fields to templates: a. Property -> operator b. Property -> website2 (new field req’d) c. BookingForm -> propertyPage d. home -> taxYear, dayMonth, month & website2 (with descriptions) 2. Amend home template for a. description of operator (& webmaster?) & website (now allowed) b. re-use of summary field as restricted access field with description/instructions (and resize) c. re-order fields as per dev system 3. Change title of home to “System” 4. Add/amend hanna codes for a. ManagementMember b. Operator 5. Edit cheque payment method to = that on the dev system 6. Add images and files pages to home 7. Change title of home 8. Re-purpose comparison field as “mailHeaders” and add to StandardMails template 9. Remove bodyTop field from StandardMails template – change body to 10 rows, summary to 3, footer to 2, update descriptions & notes in the template and update instructions in the page I think I can see that there are methods for most of that in your module, but I'm not sure about the hanna codes. The php in all my hanna codes is identical (as it just passes data to a separate script), but obviously attributes etc. are different. I don't think RockMigrations handles these, but they have convenient export/import features so that's not too much of an issue. The second migration is 1. Use findPages to detect all pages with BookingStatus in a body field (i.e bodyTop etc. as well as body – any field that can take a hanna code) – approx. 15 pages. Make appropriate changes. 2. Change the refNumber for cancelled statuses (2 pages). I can probably turn these human instructions into php (although it may be quicker just to do it in the admin, but then I definitely do not have a quick 'downgrade option!).
  7. Thanks for this; I have not heard of that method before. It is not available on my hosting either unfortunately. It looks like it is similar to readfile() but faster. From Stack Overflow: I was interested in knowing if there was a practical solution that didn't require PHP but I don't think there is and readfile() is probably the way to go. Thanks.
  8. I have the messaging module ready to go if anyone is interested in Beta testing it (then please message me) and ill get the shop up and running to sell it from (unless the PW market place is willing to have it of course???).
  9. OK so I'm in a pickle now, no email module seems to work. As mentioned above, I had been using the php mail function before, which worked ok for some time, but then not anymore. So I learned about WireMail SMTP and that sending via SMTP is always better in terms of spam protection. As required by the host (World4You), I setup an authenticated user in the settings with port 587. This worked fine for some time, now it doesn't anymore. Now I installed SwiftMail which also has test connection and test email features. I tried these tests, both are claimed successful, no errors, but no emails get received. This is scary! Is there any mail module that actually works? There are no errors neither on PW nor on the server, just success messages from PW. How to debug this stuff? Need help urgently!
  10. @psy So, just to make sure, that everything works well on the PHP side: You can make a request via Postman to the same url that you are trying to access via Javascript? And you get back the expected JSON-data? Unfortunately, I don't know much about NextJS and React. I am actually an Angular or Vanilla Javascript developer. In an Angular environment I would use Angular's httpClient to make an api-call: const params = new HttpHeaders({ 'x-api-key': environment.api_key }); this.httpClient.get('https://my-test-domain.com/api/page/1042').subscribe( response => console.log("Api-Response: ", response) ); I assume that React has a similar helper class as well. This makes a call to the page-route in my router-definition, which you can see here: https://github.com/Sebiworld/musical-fabrik.de/blob/master/site/api/Routes.php . It will return the ajax-results for the ProcessWire page with id 1042 in this case. I prefer to use the httpClient (if available) instead of the fetch function, which you are using in your code-example above. Mainly because I found the fetch function very cumbersome to use when dealing with more complex parameter data. But for a vanilla-js project I needed to use it, so I wrote a helper class that is way more usable: https://github.com/Sebiworld/musical-fabrik.de/blob/master/site/templates/src/js/classes/AjaxCall.js Here is how you can make an api-call: const ajaxCall = new AjaxCall({ method: 'GET', path: '/api/page/1042', headers: { 'X-API-KEY': 'oiasnduz3498gfsubasd' } }); ajaxCall.fetch().then(function(response){ console.log('Api-response: ', response); }).catch(function(response){ console.log('Api-error: ', response); }); I hope that helps you out 😊
  11. Hmm. Thanks, but that just seems to just resize the unformatted column. Also, if you drag it under the Tracy bar at the bottom, then there doesn't seem to be a way of getting it back 😵
  12. I figured, I will post the update: Turns out the culprit is Tracey Debugger. Once turned off, this phenomenon does not happen anymore. Luckily we only need it during installation and development of new modules really. All editors are now working with Tracey off and the problem has disappeared.
  13. The following are a few links for you to check out: Wiremail Wiremail Class: https://processwire.com/api/ref/wire-mail/ Wiremail Related Modules https://processwire.com/modules/category/email/
  14. Yesterday
  15. An update to this. As @adrian suggested, I tried out one of the db clusters at DO. I updated the storage engine from MyISAM (I could not import the MyISAM version anyway) to innoDB and did a fresh import. From the image above you can compare. Box 2 - Frontend PHP 7.4, MySQL 8 Box 2 - Admin This I can work with. Cheers!
  16. The page path is in the title attribute, so you can hover on results to see the path in the browser tooltip: PW doesn't make it easy to manipulate the markup of admin search results. You could try the hook below in /site/ready.php to append the root parent title to the result title: $wire->addHookBefore('ProcessPageSearchLive::execute', function(HookEvent $event) { $event->wire()->addHookAfter('FieldtypePageTitle::wakeupValue', function(HookEvent $event) { $page = $event->arguments(0); // Limit by template or some other property of $page if($page->template == 'basic_page' && !$page->get_original_title) { $root_parent = $page->rootParent; // Set custom page property to avoid affecting root parent title $root_parent->get_original_title = true; // Append root parent title $event->return .= " (Root parent: {$root_parent->title})"; } }); });
  17. Unpoly 2 is promised to be released soon: http://triskweline.de/unpoly2-slides/#1 Powered with Bootstrap 5 it might be a game changer for me. I have never been a fan of Bootstrap but version 5 impressed me so far. With the (optional) integration I can't wait to see what sort of productivity boost is possible for me by building upon both.
  18. 😁 I was going to mention the 2 migrations modules, but they are not part of the core. I have taken a look at RockMigrations and will do again - it's just that my last migration was too messy to use as an initial attempt. I will try using it for a simple migration first, to get the hang of it.
  19. I have not thought about the technical view, but I liked how your example really felt more "PW-ish" (like hooks) than my first approach. But I didn't like that it worked different to normal autoload modules... I came up with this idea that at least for my taste merges best of both worlds: <?php namespace ProcessWire; class FooModule extends WireData implements Module, ConfigurableModule { public static function getModuleInfo() { return [ 'title' => 'FooModule', 'version' => '0.0.1', 'summary' => 'Your module description', 'autoload' => true, 'singular' => true, 'icon' => 'smile-o', 'requires' => [], 'installs' => [], ]; } public function init() { $this->addRoute("/my/custom/{user}/endpoint/{action}", $this, "userEndpoint"); } public function userEndpoint($event) { // get parameters from route and sanitize them // not sure about the syntax? maybe $event->route->get('user', 'int'); $user = $event->api->get('user', 'int'); $action = $event->api->get('action', 'string'); $method = $event->api->method; if($method == 'GET') { // return found data as json $result = $this->wire->pages->findRaw([ 'template' => 'foo', 'user' => $user, ], ["title", "foo", "bar"]); return $this->api->json($result); } elseif($method == 'POST') { // update database // some kind of helper (https status codes etc) // would be nice, but I don't have much experience // with APIs so there might be others to talk to :) $user = $this->wire->users->get($user); $user->setAndSave('action', $action); return $this->api->success("Updated $user's action to $action"); } else { throw new Wire404Exception('Not allowed'); } } } or in init.php: $wire->addRoute("/my/custom/{user}/endpoint/{action}", function($event) { // get parameters from route and sanitize them // not sure about the syntax? maybe $event->route->get('user', 'int'); $user = $event->api->get('user', 'int'); $action = $event->api->get('action', 'string'); $method = $event->api->method; ... });
  20. Thanks @Robin S, useful to know.
  21. Roych

    SeoMaestro

    Hello, Im trying to get body field from my repeater matrix to od description in SEOMaestro bu somehow can't get it to work. Right now I get title and other fields first then the body field. How can I achieve this in default settings. Thank you R
  22. @Roope Nice module! This is an standard install on all the websites I control. Lately I had to insert al lot of MSTeams chat links on school websites, that look like this: https://teams.microsoft.com/l/meetup-join/19:cf8e53b5711b487@thread.tacv2/123456789012342540?context=%7b%22Tid%22%3a%22e957100c-9b8a-4b7f-b945-fbxx-xxxx-xxxx... Due to the @ in the link EMO tries to encode it, which of course fails. For now I excluded the page with those links in EMO settings.
  23. @monollonom That's great, thanks for pointing me to this. Exactly what I was looking for.
  24. Posted by: <?php if($page->insight_author): ?> <a href='<?= $page->insight_author->url ?>'><?= $page->insight_author->title ?></a> <?php endif ?> , <?php foreach ($page->insight_author->roles as $role): ?> <?= $role->staff_role ?> <?php endforeach ?> I would suggest something like the above, though there are certainly other templating styles. Like @monollonom said, I'm not exactly sure what role represents or how that is structured.
  25. Last week
  26. In the past, one of the primary functions of a page builder would be just to implement things like flexbox, so you could have child divs stack vertically or horizontally, or align child items vertically or horizontally, or whatnot, but now the new thing is to provide a third grid option, as an easy to use front end for handling things with CSS Grid. Check out the way oxygen just introduced CSS grid controls. I think we should do something similar in our approach. https://oxygenbuilder.com/2021/02/23/oxygen-3-7-now-available/?mc_cid=9b6f18191d&mc_eid=c2de8efb6e
  27. Issue with screencast posted: https://github.com/processwire/processwire-issues/issues/1335
  28. so what i am trying to do is that i uploded some files into file field, and then i want hook to get MD5sum and other stuff from .xml and put it into text field into it coresponding pages, pages like this are gonna be many, for each one i want it to output it into its fields
  1. Load more activity
×
×
  • Create New...