-
Posts
720 -
Joined
-
Last visited
-
Days Won
3
Everything posted by froot
-
some questions… first: checking if field exists doesn't work
froot replied to froot's topic in Module/Plugin Development
OK after some reverse-engineering, for lack of a better word… no actually reverse-engineering actually nails it. I found out that the fieldgroup's name needs to match the template's name. Once this is ensured, it works, then you can edit/remove/add/shuffle fields, all the good stuff. You're welcome ? -
some questions… first: checking if field exists doesn't work
froot replied to froot's topic in Module/Plugin Development
this remains a mystery. Also, I found another typo. Should be its and not it's ? EDIT: never mind, the typo got fixed in a later version ? ? -
some questions… first: checking if field exists doesn't work
froot replied to froot's topic in Module/Plugin Development
yes that is indeed the case, OK then it's not an issue, I just didn't know that it would do that. I can work around that then or use autoload somehow – thanks! -
some questions… first: checking if field exists doesn't work
froot replied to froot's topic in Module/Plugin Development
another issue I'm having now is that the module keeps reinstalling itself when I open the frontend. I uninstall the module, delete all related fields, templates and pages. Clear compiled files, refresh the modules (which is probably pointless), then open any site in the frontend and boom, the module is installed again along with all that I deleted manually. How can that be? It's not autoload or anything. thanks for help -
How to create template file using api under a module
froot replied to Gayan Virajith's topic in Getting Started
what an old thread… anyways, since PW is backward compatible to the extreme, I wonder why my approach doesn't work if it's so similar, see issue in this thread here… The problem being, that I cannot edit the template's fields afterwards (add/remove/change order of fields), it's not an ASMSelect field and so it's kind of locked. Here's my code to create the template and fieldgroup with if(!$templates->get('kiosk_order')) : $fg = new Fieldgroup(); $fg->name = 'fieldgroup_kiosk_order'; $fg->add($fields->get('title')); // Add title field (mandatory!) $fg->add($fields->get('kiosk_order_id')); $fg->add($fields->get('kiosk_order_products')); $fg->add($fields->get('kiosk_order_customer_name')); $fg->add($fields->get('kiosk_order_customer_emailaddress')); $fg->add($fields->get('kiosk_order_customer_address_billing')); $fg->add($fields->get('kiosk_order_customer_address_shipping')); $fg->add($fields->get('kiosk_order_payment_method')); $fg->add($fields->get('kiosk_order_total_and_shipping')); $fg->save(); $kiosk_order = new Template(); $kiosk_order->name = 'kiosk_order'; // $kiosk_order->title = 'Kiosk Order'; $kiosk_order->label = 'Kiosk Order'; $kiosk_order->fieldgroup = $fg; $kiosk_order->pageLabelField = 'title'; $kiosk_order->parentTemplates = array($kiosk_orders->id); $kiosk_order->noChildren = 1; $kiosk_order->tags = 'kiosk order'; $kiosk_order->icon = 'shopping-bag'; $kiosk_order->save(); endif; -
will wait till it's master then I guess, but good to know
-
hm... doesn't work for me. Here's my code: if(!$fields->get('custom_product_images')) : $custom_product_images = new Field(); $custom_product_images->type = $this->modules->get("FieldtypeImage"); $custom_product_images->title = 'Custom Product Images'; $custom_product_images->name = $this->wire('sanitizer')->pageName($custom_product_images->title, true); $custom_product_images->label = 'Product Images'; $custom_product_images->ext = 'gif jpg jpeg png'; $custom_product_images->tags = 'custom product'; $custom_product_images->set("textformatters", array("TextformatterEntities")); $custom_product_images->save(); endif; I think my field needs to be an "Array of items" at all times, and not "Automatic". How to define that with API?
-
is that on the dev branch 3.0.204? or master 3.0.200?
-
Admin Actions Permissions issue and more
froot replied to froot's topic in Module/Plugin Development
that works perfectly, thanks! -
some questions… first: checking if field exists doesn't work
froot replied to froot's topic in Module/Plugin Development
I changed the fieldgroup of the template in question, just to see, with a fieldgroup that I know works fine (one that I created via GUI). After saving, it still shows the fields as shown in the screenshot above. So I'm convinced it has to do with the template that I created itself, not the fieldgroup. So I did a print_r of the faulty template and another template that works as expected (again, created with the GUI) and the only things different I see are [data][editroles] = Array ([0] => 1101) [data][createroles] = Array ([0] => 1101) [ns] => ProcessWire which is missing in the faulty template. And that kind of makes sense to me because I cannot edit the fields of this template so it must have to do with permissions/roles. I doubt it's the last one with the namespace (?). But now what, how do I add a role via API? Do I add it with its ID or the name? Wouldn't that change with every installation? Thanks for help. -
some questions… first: checking if field exists doesn't work
froot replied to froot's topic in Module/Plugin Development
@ryan any idea? It also says For your reference, this is a list of fields used by this template. This template gets it's fields from the 'fieldgroup_kiosk_order' template. instead of Define the fields that are used by this template. You may also drag and drop fields to the desired order or create a new field. Seems like this is actually a wanted behaviour in some scenario I can't fathom here. -
some questions… first: checking if field exists doesn't work
froot replied to froot's topic in Module/Plugin Development
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? -
Admin Actions Permissions issue and more
froot replied to froot's topic in Module/Plugin Development
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! -
Admin Actions Permissions issue and more
froot replied to froot's topic in Module/Plugin Development
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: -
Admin Actions Permissions issue and more
froot replied to froot's topic in Module/Plugin Development
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. -
Admin Actions Permissions issue and more
froot replied to froot's topic in Module/Plugin Development
yes I did that, as mentioned here: (that's the path to that page, for me at least) -
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)
-
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.
-
I did that already, that's why I reach out. Actually, none of my actions work. They used to though.
-
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?
-
thanks for your input, will look into that.
-
how do I pass PW variables to my module?
froot replied to froot's topic in Module/Plugin Development
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 ' -
how do I pass PW variables to my module?
froot replied to froot's topic in Module/Plugin Development
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… -
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!
-
how do I pass PW variables to my module?
froot replied to froot's topic in Module/Plugin Development
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?