• Content count

  • Joined

  • Last visited

Community Reputation

24 Excellent

About Karl_T

  • Rank
    Full Member

Contact Methods

  • Website URL

Profile Information

  • Gender

Recent Profile Visitors

645 profile views
  1. Looks like it is a good place to extend for my need. Thanks a lot! Right now there are too much fields to choose from. This will make my customer nervous.
  2. Greeting. I am looking for a way to have a user defined criteria on each page. It would be best to be a field inside the page editing, then maybe output a, or array of, selector string when call. Every page can have different criteria input by the user. The user interface would be something like the filter inside the Lister, with AND, OR for multiple criteria. The usage maybe like this: $criteria = $pages->get(1234)->criteria_field; // OR field become array of selector string $valid = false; foreach($crieria as $c){ $valid = $pages->find($c)->has($page); if($valid){ // do whatevery if the page fit the criteria break; } } Above is just my imagination. Is there anything close to this in PW at the moment? Or, is there any proper way to achieve this using PW native method? I want to have this to check: Page's parent(s'), own, children's template, name, field value etc Thanks.
  3. I used to use $pages->get($id) to get the page. I assumed they work the same as repeaters are pages behind the scene. My bad. Thanks @Robin S again!
  4. I want to use the following code to delete a repeater item, $item = $p->repeater->get(2011); //get the item by page ID $p->repeater->remove($item); $p->save(); but it fails. the get method is looking for repeater item ID started from 0. After some testing, the repeater item ID is just like any array key. If someone using that to track an item, wrong items could be deleted/edited due to the dynamic item ID. Also, it is quite weird that when I want to get the repeater item ID like foreach($repeater as $item){ return $item->id; } it returns the repeater page ID instead of the repeater item ID. It is actually how I get the repeater page ID lol. What I mean weird is that the get method above is not looking for page ID while when I ask for item ID from it, it returns page ID. So, I decided to use page ID again to move repeater item after all these trying. I am using the following code to remove repeater item. $item = wire("pages")->get(2011); $p->repeater->remove($item); $p->save(); It works. However, it seems like it is not the designed way, more like a workaround. Please advise if there is any native way. Thanks.
  5. It did the trick! Thanks @Robin S!
  6. Hi @Hosted Power. Currently session lock is missing in the module. I am currently busy on my own project. I will make a pull request to netcarver's repo with the session lock implemented some time later, maybe a month later as I want to use this on my project too. I will post it here after that.
  7. Greetings. I am trying to use API to add new page with a repeater field. I am following this link https://processwire.com/api/fieldtypes/repeaters/. Using the code similar as below. $p = new Page(); $p->parent = wire("pages")->get("template=something"); $p->template = 'some-template-name'; $p->name = 'some-name'; $r = $p->repeater->getNew(); $r->field1 = 'somthing'; $r->field2 = 'somthing'; $r->field3 = 'somthing'; $r->save(); $p->repeater->add($r); $p->save(); The page is added successfully, but, with 2 identical repeater item inside the repeater field. This is the first issue. And then I remove the second last line and become $p = new Page(); $p->parent = wire("pages")->get("template=something"); $p->template = 'some-template-name'; $p->name = 'some-name'; $r = $p->repeater->getNew(); $r->field1 = 'somthing'; $r->field2 = 'somthing'; $r->field3 = 'somthing'; $r->save(); $p->save(); The duplicated issue is gone. The second issue then comes. When adding new page using above code, a repeater page with same title is added under the path /cms/repeaters/for-field-280/for-page-0/, while the normal one is added under /cms/repeaters/for-field-280/for-page-2011/. The page /cms/repeaters/for-field-280/for-page-0/ cannot be deleted. And the children page under it just keeps growing when I add new page. I believe this is the cache remained because I deleted the line. I think I can just leave the page there, but I cannot. I don't want unwanted things appear and grow. Maybe I have missed something. I want a proper way to add page with repeater fields. Thanks!
  8. You are right. I thought they are the same thing. Sorry for the misleading.
  9. I was editing a field setting in the admin panel. This happens also when redirecting to the edit page after you create new inputfieldwrapper field.
  10. Thanks for the module. I would like to report that It seems that this module is breaking the inputfieldwrapper field. When I edit the inputfieldwrapper field, it shows error as following. Error: Uncaught TypeError: Argument 2 passed to ProcessWire\InputfieldWrapper::insertAfter() must be an instance of ProcessWire\Inputfield, null given, called in /var/app/current/site/modules/CustomInputfieldDependencies/CustomInputfieldDependencies.module on line 136 and defined in /var/app/current/wire/core/InputfieldWrapper.php:296 Stack trace: #0 .../site/modules/CustomInputfieldDependencies/CustomInputfieldDependencies.module(136): ProcessWire\InputfieldWrapper->insertAfter(Object(ProcessWire\InputfieldTextarea), NULL) #1.../wire/core/WireHooks.php(782): CustomInputfieldDependencies->addFieldOptions(Object(ProcessWire\HookEvent)) #2 .../wire/core/Wire.php(442): ProcessWire\WireHooks->runHooks(Object(ProcessWire\Field), 'getConfigInputf...', Array) #3 .../wire/modules/Process/ProcessField/ProcessField.module(943): ProcessWire\Wire->__call('getConfigInputf...', Array) #4 .../wire/core/Wi (line 296 of /var/app/current/wire/core/InputfieldWrapper.php)
  11. Thanks! This just works, although this has a 0.5 second delay due to separate ajax call.
  12. I want to make some branches of a page list(tree) open onload. I am using Admin Custom Page module with the following code. <?php $p = $this->modules->get('ProcessPageList'); $p->set('id',1037); return $p->execute(); I changed the parent successfully from home to the wanted page, but the tree closed every time after reload. I added the following code before return $p->execute(): $this->wire('config')->js('ProcessPageList', array( 'openPageIDs' => array(1045,1046), )); The javascript shows error. Then I tried this: $this->wire('config')->js('ProcessPageList', array( 'openPageIDs' => 1045, )); The branch of the ID open with delay. I want to open multiple branches at the same time. Thanks.
  13. This would be great. I would like to contribute.
  14. @seddass Thanks for your great lesson. I have really learnt a lot! I lack the knowledge and sense to find out the potential threats. And, I should have made it clear about the existence of any open issues affecting the usage before using a library. I will dig deeper and try to resolve the issue. Your attached code would be a great help for this. I was using string as datatype originally. Hash is used because it is the only way I found that can let me to do calculation like finding recent active session using timestamp by ZADD. Thanks for poitning this out. I overlooked this one.
  15. Hi @Zeka Although this does the trick to prevent log out, I still would want to get the client's real IP address as stated. I found that this is not possible right now as the getIP method Processwire using do not have a place for setting to read new header. I added a feature request for this issue here: https://github.com/processwire/processwire-requests/issues/92 Edit: Sorry, I have made a mistake. Setting $config->sessionFingerprint do nothing to IP storing. The way to get the forawrded client's IP is using something like $sessoin->getIP(false, 2); instead of $sessoin->getIP(); The key is the second parameter. I got logged out even though I set $config->sessionFingerprint = 12; If I find out the reason I will report back here. I can confirm that my own IP address is fixed.