Jump to content

froot

Members
  • Posts

    707
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by froot

  1. really curious about this one, I'm concerned that something is not well configured and will cause damage in the future. Why aren't the individual fields listed within a ASM-Select field as usual?
  2. yes, that solved the first issue actually. And somehow this seems to have messed up all other actions too, because I was able to execute other actions even though they had required fields. So I got no error when submitting, but after that, the server loaded and loaded and then threw a "memory exhausted" error. Then I tried with a very small (2 lines) .csv file (which is the required field) but the result was the same: memory exhausted. All of that made no sense to me either Adrian. But thankfully that's gone now because the unpopulated required field impedes the process. Maybe it was still worth mentioning? Anyways, thanks so far! However, speaking of required fields, I have another question… I have a dropdown field in my defineOptions method like so: protected function defineOptions() { return array( array( 'name' => 'content', 'label' => 'Content type', 'description' => 'What is this content for?', 'type' => 'select', 'required' => true, 'options' => array( '0' => '', '1' => 'category1', '2' => 'category2', '3' => 'category3', '4' => 'category4', '5' => 'category5' ), 'value' => '0' ), ), } but it would just ignore the required property, no errors when nothing is selected. What am I doing wrong? And lastly, I'm wondering if it's possible to show content on the results screen? So far I can only show a message like $this->message("that's all I can do here"); Thanks a lot Adrian!
  3. it's two issues, not sure if related. Issue #1 one is, I'm lacking permissions to execute a custom action. To find out if it's my code that's causing the problem, I tried something very simple first instead. class saveOrShow extends ProcessAdminActions { protected $title = 'saveOrShow'; protected $description = 'save or show'; protected $author = 'FRE:D'; protected $executeButtonLabel = 'DARE'; protected $icon = 'shopping-basket'; protected function defineOptions() { return array( array( 'name' => 'parentPage', 'label' => 'Parent Page', 'description' => 'The parent page of orders', 'type' => 'pageListSelect', 'required' => true ), array( 'name' => 'saveOrShow', 'label' => 'save or just show?', 'type' => 'radios', 'optionColumns' => 1, 'options' => array( '0' => 'show', '1' => 'save' ), 'value' => '0' ) ); } protected function executeAction($options) { return ':D'; } } But that's just not allowed. I get And here's the permissions settings pages:
  4. but I should say, that's not the issue, I don't need let alone want guests to be able to execute the action, I just read somewhere that that could help (?). I just need it to work for superuser.
  5. yes I did that, as mentioned here: (that's the path to that page, for me at least)
  6. I thought I'd start a new threat for this issue, I don't like typing in the module's initial support threat too much, maybe the issue is just very specific to my stupidity and nothing of general interest. Run Sorry, you do not have permission to use this action. when trying to run my custom admin action. In permissions, I gave the superuser all available permissions, and the guest user I gave permissions to Run selected AdminActions actions Run AdminActions restore feature in /admin/access/roles/edit/?id=37 and /admin/page/edit/?id=37 (don't know what's the difference) as well as page edit permissions in the role settings and in the template settings relevant to the executed action (so I tried many things) but none of it works. "guest" however doesn't appear in the available roles dropdown in /admin/module/edit?name=ProcessAdminActions And the other issue is, not sure if it's related, I can run all actions, though not successfully, even in spite of not filling the required fields. I get an error like memory exhausted. I tried on localhost (MAMP) and remote web-server as well. PW version 3.0.200 Admin Actions version 0.8.12 php version 7.2.34 (MAMP) and php version 7.3.33 (world4you.com)
  7. what's also weird is that now the actions are executable with no need to populate the options fields where I set 'required' => true. The actions run nonetheless and I get some Allowed memory size of 536870912 bytes exhausted Error. How can that be? It should not execute in that case. I have never changed that module and the page actions ever since it worked properly.
  8. I did that already, that's why I reach out. Actually, none of my actions work. They used to though.
  9. I'm getting Sorry, you do not have permission to use this action. when trying to run a custom action. I have role superuser and I gave superusers all available permissions though… What could that be?
  10. thanks for your input, will look into that.
  11. thanks! I will try that there's a typo BTW // set and save a meta value $page->meta()->set('colors', [ 'red, 'green', 'blue' ]); missing a '
  12. I agree, pages are easier to use and I got it to work already. I just thought it would be easier and more flexible to store the entire input in json format in a field on that page instead of, when installing the module, creating specific fields for that template. Because if it's just json in a field, it would be much easier to add fields that weren't there at the time you installed the module and more versatile for different users – talk about Nächstenliebe. Does that make any sense? Or maybe there's a more PWish way for that scenario as well…
  13. The thing is, I need to catch anything that php would echo out because it's an AJAX-response that I would parse in the frontend. If it's anything else than valid JSON, JS crashes and stops. So I either try and catch errors when awaiting the AJAX-response in the frontend or try and catch all errors, exceptions, warnings, notices and whatnot in the backend. I'd say the latter is the more elegant solution cause that way all server related issues would be handled on the server, kind of. I do sent what is caught, if it's of interest to the user, nicely json-encoded to the frontend however, which brings me to my next question. How can I bail out if an error was thrown manually or thrown automatically by PW of PHP? This doesn't work, there's always a message… if ($err->getMessage() != '') { // send to user } else { // send to me } Anything I would throw manually is meant for the user to see, anything else is not but is sent to me via email or logged somewhere. Does that make sense? Thanks for help!
  14. OK here's a follow up question. Since each data set I would create a page with is a simple php array to begin with, and since I would only return this data in a "Process"-module anyway (the pages themselves are of practically no interest), wouldn't it make more sense to just store the entire array, json encoded in just one (e.g. text-) field? I reckon that way you could add to the data sets more easily and the data would also be more easily accessible for potential further application. What do you think?
  15. I have another question concerning fieldgroups. The installation now seems to work flawlessly, the module installs fields and fieldgroups and template with these fieldgroups. When editing the template in the GUI, I get a different interface to what I am used to when the template was created in the GUI, see screenshot attached. Does that raise any red flags? Why can't I add other fields to the template? Is that a security measure of some sort? What are other limitations apart from the obvious one?
  16. thanks for the input, I'm a step further now. Is there a way to catch a PHP Notice? I'd like to stop the code and handle appropriately or at least create a log or get an email if anything goes wrong so I can debug. Because it's quite a work load to anticipate everything that could go wrong and throw exceptions manually… Right now I can only catch \Exception, \Throwable and WireException I believe.
  17. OK I it looks like I need to catch the exceptions manually, thus evaluate the return values. Anyways, It's easy to throw an error/exception if you know what can go wrong but I cannot anticipate everything that could go wrong so how to catch any type of error? Can I catch internal server errors?
  18. I'm having troubles understanding some basic php… How can I catch errors of nested methods… Do I need to check for the 'error' key in the the $result variable manually? Or like make subMethods1 return true/false and check for that in the topMethod's try block? I still want to return what the error was in the subMethod… class myClass extends WireData {s public function topMethod($item) { $result = []; $result['title'] = $item['title']; try { if ($item['title'] == 'subMethod1') { $array = $this->subMethod1($item); $result = $this->mergeArrays($array, $result); } if ($item['title'] == 'subMethod2') { $array = $this->subMethod2($item); $result = $this->mergeArrays($array, $result); } } catch (WireException $e) { $result['errors'] = $e; } return $result; } protected function subMethod1($item) { try { $result['foo'] = 'bar'; $result['foobar'] = 'foobar'; $result['yada'] = 'blah'; echo $unKnownVariable; // throws error return $result; } catch ($e) { $result['error'] = $e; return $result; } } protected function subMethod2($item) { try { // ... } catch ($e) { // ... } } protected function mergeArrays($array, $result) { foreach ($array as $key => $value) { $result[$key] = $value; } return $result; } }
  19. there's a new version on github now that also installs a stack_prices repeater field and a ready-to-use product template. Hope that helps. I'm trying to give users with guest role permission to view (at least) the kiosk dashboard page on kiosk.datajungle.xyz, but don't know how yet. Any help is welcome. If you installed the first version and want to use the new one, uninstall while still on the first version because I renamed the templates and fields and whatnot to keep it more consistent. Sorry about the inconvenience, if there's a better way to do it? Still learning how to use the "update" functionality of modules.
  20. always struggling with this. How to get the only or first image what ever the images field type (array or single or automatic)? // check if there is one if(count($item->images)){ echo $item->images->first->width(200)->url; } Doesn't work in all scenarios though… what if the field is NOT an array and only has one image? what if the field is NOT an array and empty? what if the field IS an array but only has one image? what if the field IS an array but empty? what if the field IS an array and there are multiple images? (probably the only scenario where the above works). Can someone who's been there before provide a code that covers all and never throws an error, just stays empty if there is no image?
  21. That happens when a new $_SESSION is started. It stores two empty arrays in that variable, one with key 'kiosk' and one with key 'PayPalSession'. These arrays get filled later. When you refresh it's gone. Not a big problem, will fix it in the next update.
  22. I think the issue is, like I mentioned before, that many devs don't want their module to rely on yet another third party module to function (install/uninstall) correctly. What if the module is discontinued some day or outdated? What you could do, just an idea, is make the migrate module serve the same purposes it does already, but instead of offering methods, generate the code that would work with pure PW that developers can put in their module. Also, not sure if that's possible or this or another module offers that already, allow for fields and template export. So what happens a lot to me at least is, I work on a site, create some fields and templates via GUI and when I'm happy I want these fields in another installation or better yet (from now on at least) included in a module. Then I would need to re-overthink what I did via GUI to accomplish the same thing via API. If you could just use RockMigrations, navigate to the field(s), template(s) or even page(s)? in question and click click bing bang boom it shows you the API-code you need for PW to install it in anywhere else.
  23. so… public static function getModuleinfo() { return [ 'installs' => 'RockMigrations', ]; } I'm sure this module rocks, pun intended. When will it be a core module?
  24. You can create a field stack_prices as a repeater field with three subfields: repeater_product_quantity (integer), repeater_product_stackprice (float) and repeater_product_shipping (float) Add this field to your product-template. Then, on your product page, before you render the add-to-cart button with ___renderBuyButton() you can format these values like so: if ($page->stack_prices != '') : $product->stack_prices = array(); $i = 0; foreach ($page->stack_prices as $sp) : $pricing = array( 'qu' => $sp->repeater_product_quantity, 'sp' => $sp->repeater_product_stackprice, 'sh' => $sp->repeater_product_shipping ); $product->stack_prices[$i] = $pricing; $i++; endforeach; endif; and then send it to the function: echo $kiosk->___renderBuyButton($product); I want to include this field in the module to be created upon installation soon.
×
×
  • Create New...