Jump to content

chrizz

Members
  • Posts

    126
  • Joined

  • Last visited

Everything posted by chrizz

  1. whoop. Perfect! Thanks for that link ?
  2. I already checked the CaptainHook cheatsheet - only the httpUrl method for PageFiles is hookable. It looks as if hooking the counterpart for pages is not possible ? I currently use httpUrl at many places in the code but the URLs need to be rewritten. When hooks are not appropriate: Is there a way to add a custom method for all pages (e.g. $page->myCustomPath()) which actually returns the URL I need?
  3. nahhh.... I found the issue. If I would have followed @LostKobrakai advice: serialize can cause unforseen issues. The above example works fine, but actually (and I didn't test this yesterday) I (un-)serialize the array before replacing one item. When I use the example and serialize WireArray before getting and replacing the element it simply does nothing but it shows the old item I guess I have to go with the "use pages for every item" solution which is much less error prone. thanks @kongondo for testing this
  4. I have a WireArray which holds objects of type WireData. I use WireArray because I would like to utilize the capabilities of using selectors to find items. My current use case is to find one specific item, modify one value and put it back to the WireArray. The code (simplified) looks like this: // fill the array $arr = new WireArray(); $item1 = new WireData(); $item1->text = "lorem ipsum"; $item1->identifier = "123"; $arr->add($item1); $item2 = new WireData(); $item2->text = "lorem ipsum"; $item2->identifier = "456"; $arr->add($item2); $item3 = new WireData(); $item3->text = "lorem ipsum"; $item3->identifier = "789"; $arr->add($item3); // use the array $myItem = $arr->get("identifier=456"); $myItem->text = "some other text"; // update the item in the array ? Is there any trick to store the modified item in the array again? Removing the old item does not work because I don't know how to retrieve the key of $myItem Adding the item just duplicates it Replace the old item does not work - it keeps the old item Any help is appreciated! I hope that there is a solution - otherwise I have to replace the whole construct with single pages (which would be overkill) Thanks a lot!
  5. thanks for your input. I think serializing is the way to go for now. The closest pw-way would be probably to create new templates holding all the data, but for now this would be overkill ?
  6. I was wondering if there's a PW-way to store a WireArray permanently in a field and restore the WireArray whenever needed. Currently I can only think of (un)serialize or getArray() and then storing the array as JSON. It there's no better way - fine. If there is something more PW-related, I'd be happy if you share it ? Thanks!
  7. as usual: Layer8 problem. ? I just messed up with the field names. It works as expected as shown in the example above.
  8. @LostKobrakai, that was one of my thoughts as well. But I am building a form in a frontend template without any PW javascript (at least I am not aware of that). And because of that I tested if this is probably only a backend functionality in PW admin - but as said: it works as soon as the requiredIf is related to a text field. But anyways: I recognized that the Datetime field has some issues anyway. It's worth fixing them first ?
  9. I am currently building a form (used in template) which includes a datetime inputfield (date of birth) and a radio input (+some other inputs). What I am trying to achieve without success so far: Based on the datetime input the radio field needs to become required. $field = $this->modules->get("InputfieldDatetime"); $field->label = "DOB"; $field->attr("id+name","date_of_birth"); $field->attr("type","text"); $field->dateInputFormat("d.m.Y"); $field->required = 1; $field->customError = "Birthday missing"; $form->add($field); $field = $this->modules->get("InputfieldRadios"); $field->attr("id+name","confirmation_underage"); $field->attr("type","text"); $field->addClass("validate"); $field->addOption(1,"lorem ipsum"); $field->addOption(2,"lorem ipsum"); $field->required = 1; $field->requiredIf = "date_of_birth>1557180000"; $field->customError = "Missing value!"; $form->add($field); I confirmed by testing, that the requiredif works when it is dependent on a text field (e.g. first name) and the first name matches the condition. I assume that there is something fishy with the unix time stamp in that condition but I didn't find any examples. Printing the field value shows the timestamp (as integer). As usual - any help is appreciated ? Thanks a lot!
  10. Makes sense. I will have a look at this.
  11. I was wondering if there's a way to select multiple dates in one field, like it's done here: https://codepen.io/ranjith555/pen/OyKjjm Something which goes into the right direction would be this: https://modules.processwire.com/modules/inputfield-recurme/ but this sounds a bit like overkill just just selecting multiple dates. Any ideas are appreciated ?
  12. Sounds like a pretty nice idea, but in the end I think it does not work, as the structure is a bit more complicated than presented. The whole thing ends up in some kind of Rest API. Static containers are returning a list of user-specific content - therefore Currently I have URLs like this (red = user specific, blue = general path) domain.com/api-v1/container1/custom-content-1/container1-1/custom-content-1-1/ This works perfectly with one user, but as soon as you have a second user the whole thing becomes more tricky. Either the URL would end up like this (which feels weird) domain.com/api-v1/user1/container1/custom-content-1/container1-1/custom-content-1-1/ or permissions are applied to all custom content so that the structure can stay the same as in the first example. Working with permissions here might be replaced with $pages->find() if each user-specific page can be identified. And the final solution has been found here: In the end I will use api-v1/ with URL segments. Based on the authenticated user the segment is passed to $pages->find() link this: if($user->isLoggedin()) { $pages->find("/data/".$user->id."/".$input->urlSegmentStr) }
  13. the overall goal is some kind of API which returns content on an endpoint which is user-specific. container1 and container2 are the endpoints which return such user-dependent content. technically it would be user-n/container2/ - but visible to the user would be only container2/ In a way it's stripping out the /user-n/ part and handle it implicitly via the given authorization.
  14. I am currently thinking about a potential site structure which is based on the authorized user. The currently desired structure in the backend would be something like this: user1 container1 custom-content-1 container2 custom-content-2 custom-content-3 user2 container1 custom-content-1 custom-content-2 container2 custom-content-3 custom-content-4 There are two pages which are common and user-independent: container1 & container2. Everything below these common pages depends on the user. Ideally these pages can be access like this: User 1 can access https://domain.com/container2/ and see's custom-content2 & custom-content3 If user2 access the same URL he would see "his" custom-content3 & custom-content4 Any unauthorized user would get an error message. What do you think about this approach? Do you have better ideas how this can be tackled? While writing: What about merging everything in one container but apply specific rights for every page individually? Is this a scalable solution even with 1000 users?
  15. Sorry for pushing this but I still hope that someone has an idea. Maybe you are using a different IDE? Or you are not testing as all?
  16. Hey guys, I am recently migrated my whole setup to a newer environment, using Vagrant, webpack and the latest version of PHPUnit. Everything works fine except the tests are driving me crazy. It worked long time ago already but nowadays I have some trouble with the test output and I hope that someone has an idea. If I run a single test via my Eclipse IDE it works perfectly and the output as shown as expected. I see all tests in a nice overview including all passed and failed tests. But as soon as I include the index.php from the root directory to utilize the PW API the output is killed completely. Something must cause interferences between PHPUnit and including the PW API. I am using PW 3.0.62 and tried with PHPUnit 6.5.14, 7.5.8, 8.1.2 and PHP 7.1.28, 7.2.16. Regardless which configuration - it all ends when PW is included ? Any ideas where I might dig into are really appreciated.
  17. Yes, the site is also hosted on 1&1. And no, also gmail does not work. So proabably something wrong with 1und1. Will ask the support. Error message is Thanks for pointing me to the obvious things ?
  18. I am having trouble setting this module up on the client's webspace. Locally it works like charme with the given data (as seen here - only in German: https://www.ionos.de/hilfe/e-mail-office/allgemeine-themen/einstellungen-fuer-ihr-e-mail-programm/) Locally I use SSL via port 465 (host: smtp.ionos.de) After copying the whole processwire installation to the clients webspace I updated the hostname but then out of the sudden the SMTP server isn't reachable anymore via SSL (nor TLS). Only unecrypted connections are working. Is there anything obvious I am missing? Thanks a lot for your support!
  19. @kixe Awesome! I guess that explained in pretty much in detail! And guess what: after ignoring this problem for 24h now it solved itself... like always ? Thank you very much for this detailed explanation!
  20. this question can be also asked on stackoverflow, but I think supporting the local forum is much better ? I discovered the following issue while using PHPunit tests to cover some module methods: If I declare an array in the init() method of a module it's not accessible in another method called from the testcase. If I move the same array initialization to the __construct() method it's working as expected. I am not sure if this is an issue with PHPunit, PW or just a misunderstanding by me. Is there anyone out there who has some more expert knowledge about this? Thanks!
  21. to finalize this approach if($f->type->manager->getOptions($f)->has("title=".$this->input->whitelist("userInput"))) { // user selection is valid }
  22. I was wondering if there's an easy way to validate if a title is a valid value for a FieldtypeOptions field. I have created a field with different status values where only a single value can be selected: 1=done 2=planned 3=error Now I am going to update the page which includes this field which works fine so far - but: I I am using any other string than the defined options it stores a blank value. To avoid this I am trying to validate the input before. Something like getAllOptionsForField > in_array() etc would work but maybe there's a build-in method I am currently missing? Long story short: how would you validate if the given string is a valid option for a field? as usual: Thanks
  23. thanks everyone for clarification. It was obvious as it wasn't mentioned in the documentation but sometimes asking for help offer new implementation approaches :))
  24. hey there, I was wondering what the best approach looks like to access the input (entity) body from a POST or PUT request. I didn't find anything in the docs if $input supports these. If anyone has dealt with this problem in the past I'd be happy to hear about your solutions Thanks & cheers!
  25. awesome! thanks so much @adrian!
×
×
  • Create New...