-
Posts
1,523 -
Joined
-
Last visited
-
Days Won
21
Everything posted by elabx
-
Importing JSON to pages - updating existing page/deleting
elabx replied to nsc's topic in API & Templates
If i'm not missing any detail, you can just call this in you if clause: https://processwire.com/api/ref/page/delete/ if($exists->id) { echo $exists->delete(); } else { ... } -
How to access to a specific repeater item based on a field value?!!
elabx replied to WireCodex's topic in API & Templates
Repeaters are output as PageArray (or rather a class that inherits from it, called RepeaterPageArray), so you have all the methods from a WireArray such as: https://processwire.com/api/ref/wire-array/get/ https://processwire.com/api/ref/wire-array/find/ $page->repeater_field->get('FieldA=2')->FieldC -
New blog post: WEBP strategies, Google Client API, FormBuilder and more
elabx replied to ryan's topic in News & Announcements
Just awesome feature! I'm testing the output strategy with the hook, but I can't seem to make it work if the url() method is preceded by size(). Anyone bumped into this? Ended up using method without the hook, leaving the jpg extension. Works just fine ? -
I got curious and debugged into this because I ran into a similar issue with prev() method while rendering a repeater matrix field, and had to include the 'check_access=0' selector to actually find a prev() page while a guest user visited the page, though I'm not being able to to this with index() too, like: $page->index('check_access=0'); Maybe you can try it and see if it works for you?
-
Awesome! Thanks a lot for your help! Actually found this myself yesterday working through the PW source code (I really LOVE being able to do this).
-
Wow thanks! With the module, is it possible to render the fields with their renderValue() ? Like the access permission does! It let's you view the inputfield, but doesn't display as an actual input but just the value. Thanks for your help! Will definitely take a look at your module.
-
Hi everyone! Does anyone know if I can tweak field access on runtime to hide fields in ProcessPageEdit depending on some other field conditions. Eg. I want users to be able to edit the data if they are asigned to said page, or they created it and if not, hide the fields. Right now I'm wiping the fields with a hook on ProcessPageEdit::buildFormContent, but for example, I'd like to leave the title field intact and some other "common" fields amongst the users.
-
custom php code to find selectable pages + autocomplete
elabx replied to bernhard's topic in General Support
Does anyone know if custom php code this still doesn't work with single page selection with autocomplete? From comments around here and last comment by Adrian on this github issue it would seem to be able to work but I just can't get my hook to do anything to the page selection. -
Ok, then again if I understand correctly you want to set permissions on a page using a Page Referece field (to select a role), being "y" the page being edited? Probably last think I don't understand is if you want to block the edit page or the frontend page (rendered with the template) If the case is blocking the edit page for a certain role, you could hook into the Page::editable() (haven't tested this code): wire()->addHookAfter('Page::editable', function($event) { if(!$event->return) return; // already determined user has no access if(wire('user')->isSuperuser()) return; // superuser always allowed $page = $event->object; if($page->template == "y_page_template") if($page->relatie->has($this->user->roles)){ $event->return = true; } else{ $event->return = false; } } }); Here I am assuming Relatie field actually selects roles in ProcessWire, since those are pages too.
-
I think, if you mean the actual pages selected, you have to check for the template permissions of the selectable pages. Field access will show/hide the actual field for different roles.
-
Date field output formatting with strftime() not outputting AM/PM
elabx replied to elabx's topic in General Support
Just tried this with no success, now that you say so, capital letters are not working but they do fallback to the lowercase version. I'm reading that it's kind of a common issue that I'm guessing have to do with the server configuration. I'll have to take a linux dive then. -
The most simple approach I can think of right now is hook into after InputfieldText::render: Put this code in site/ready.php: $wire->addHookAfter("InputfieldText::render", function($event){ $field = $event->object; if($field->name == "text_field_name" && $field->value){ $markup = $event->return; $url = "https://somedomain.com"; $markup .= "<img width='100' src='". $url . $field->value ."'>"; $event->return = $markup; } }); I'm assuming $url is whatever you need to append to complete the url with the ID in place. This should render the image right below the text input. If you want to dig a bit more, check the code in the link I pasted and debug with a $log->save() the $markup variable which basically gets it's content from the $event->return property which matches the return value of the render function in the Inpufield code.
-
Hi everyone! I have a datefield I want to output in spanish in a lister but when I configure the time such as this: %b %e %a %l:%M%P I just can't get the AM/PM part of it to output ?. If i just use the dropdowns for date() formats, it works just fine. Spanish locale seems to be setup correctly because everything else language-wise works well. Has anyone came accros this issue?
-
The field has an option for a default value though it will only apply to newly created pages (in case you have previously created some of them). My bad, this does not exist haha, I think only integer has this. But you could certainly do this with an "after hook" on ProcessPageEdit::buildForm and edit the value of the field in question. I dont have an immediate example but there is probably some around the forum
-
I don't think this is possible right now with Ryan's code.
- 1 reply
-
- 1
-
-
OHHH you know what, I'm plain wrong. The problem with processPageEdit is that it redirects on init if there is no page id in the query parameters, so unless you add that parameter to your request, it will always redirect. https://github.com/processwire/processwire/blob/master/wire/modules/Process/ProcessPageEdit/ProcessPageEdit.module#L358 Also its hould be preceded by the word execute, and camelcase the method name. What I had ACTUALLY done, is hook right before page edit and just halt execution when I'm done with my stuff, but surely this doesn't feel really clean. https://github.com/elabx/InputfieldExportFiles/blob/master/InputfieldExportFiles.module#L30
-
Something I have done is add a method through a hook such as: $wire->addHook("ProcessPageEdit::executeCustomModule", function(){ ... }) So then you can make a request to: page/edit/custom-module
-
Hi! Small request here, just added Input Mask to integer fields tweaking a little bit of lines in the module, maybe this should be enabled by default? Anyone see any possible issues, maybe on number type inputs? I think it's the type of field where it is particularly useful so you can filter nicely with selectors. (think of a price field)
-
Better way to check for minimum count if($total > 3)
elabx replied to hollyvalero's topic in General Support
Yes sorry! Jumped ahead too fast! Now I am in intrigued too ? Could you throws us a lead @jens.martsch ? Like, I cannot find PaginatedArray or PageArray classes to have their own implementation of count. -
Better way to check for minimum count if($total > 3)
elabx replied to hollyvalero's topic in General Support
What's happening is that integer 0 loosely evaluates to false and any value 1+ evaulates to true: https://www.php.net/manual/es/types.comparisons.php#types.comparisions-loose -
Better way to check for minimum count if($total > 3)
elabx replied to hollyvalero's topic in General Support
It's a debug command from Tracy Debugger module. -
Maybe here?? https://github.com/processwire/processwire/blob/master/wire/core/Pagefiles.php#L409
-
If any of the alternatives work I'd still wonder why his original code wouldn't work.
-
The real MVPs!!
-
Save page in PageTable field before close event on Add New modal.
elabx replied to elabx's topic in General Support
Thanks, definitely overdid it there ?