Karl_T

Members
  • Content count

    87
  • Joined

  • Last visited

Community Reputation

35 Excellent

About Karl_T

  • Rank
    Full Member

Contact Methods

  • Website URL
    karl.tai.dev@gmail.com

Profile Information

  • Gender
    Male

Recent Profile Visitors

845 profile views
  1. Wow, this is exactly what I am looking for. Great thanks!
  2. Currently the page tree(name=page) under admin is locked. I would like to generate a page to place above the page tree, using $page->sort = 0, but it is not possible before removing the statusSystemOverride attached to it. I tried to remove the status like this: $pages = $this->wire('pages'); $tree = $pages->get('name=page, template=admin'); $tree->removeStatus(Page::statusSystemOverride); $tree->save(); And recover the status after saving my generated page $p = new Page(); $p->template = 'admin'; $p->title = 'Some Page'; $p->name = 'somepage'; $p->parent = $pages->get(2); $p->process = 'SomeProcess'; $p->sort = 0; $p->save(); $tree->addStatus(Page::statusSystemOverride); $tree->save(); And the Page group is disappeared on the sidebar. I cannot recover it and need to reinstall the PW. I am developing a module so I would like to know the correct way to place page above the page tree by API not by drag and drop. Thanks.
  3. テラバトル2のアイテムゲットガチャで、激レアクラスの守護者をゲット!! #DMMGAMES #DMMガチャ[09/09 15:15:37] https://t.co/D2E8o65Hoy

  4. I solve the problem by overriding the LanguageSupportPageNames core module. 1. Copy the LanguageSupportPageNames.module from wire/modules/LanguageSupport/ to site/modules/ 2. Change the line if(!$setLanguage) $setLanguage = $languages->get('default'); to (for example, if you want to redirect some users to chinese site) $user_lang = explode(",", $_SERVER['HTTP_ACCEPT_LANGUAGE'])[0]; if($user_lang == 'zh-TW' || $user_lang == 'zh-HK' || $user_lang == 'zh-CN' || $user_lang == 'zh-SG') { if(!$setLanguage) $setLanguage = $languages->get('chinese'); //language name that you want to redirect from the above language code }else{ if(!$setLanguage) $setLanguage = $languages->get('default'); // else go to default language } 3. Go to Admin > Modules and refresh modules. Choose to use module inside site/module/. In this way, when no language segment is entered in the URL, the user will be redirected according to their HTTP_ACCEPT_LANGUAGE header. On the other hand, URL with language segment will not make any redirect.
  5. I would like to know how to hook or change the behavior that when I go to URL without the language segment. For example: If the domain is www.abc.com English(default) URL is www.abc.com/en/ Japanese URL is www.abc.com/jp/ When I browse www.abc.com, it redirects to www.abc.com/en/, which is the default behavior after I set "Default language homepage URL is same as root URL?" to "NO" inside "Languages Support - Page Names" module config. I would like to change this hard redirect to check the user browser language before redirecting to other language. For URL that having the language segment should not be affected. That means browsing www.abc.com/en/ is always go to English language without redirect. I want to apply this change to any frontend pages, not only homepage. Thanks.
  6. Thanks. I put <?=$session->CSRF->renderInput();?> somewhere inside template. And then do something like the following inside js. var data = { 'firstname': $("#firstname").val(), 'lastname': $("#lastname").val(), }; var CSRF_name = $("._post_token").attr("name"); var CSRF_token = $("._post_token").val(); data[CSRF_name] = CSRF_token; $.ajax({ url: "/ajax/", data: data, method: 'post', }); then inside ajax.php if($session->CSRF->hasValidToken()) { //do something } This works.
  7. For some reasons I am not submitting a form but individual input fields via ajax. I would like to use SessionCSRF to protect from cross domain request. Is it possible to make SessionCSRF work in this case? And how? Thanks.
  8. Fixed. The time of modified, created and changlog(module) is reading the database server timezone. I am using a remote database, so the timezone is different from the web server. The issue fixed after changing the remote database server timezone.
  9. Greeting. I am having hard time trying to make the time inside processwire correct. I have a correct server time. I have a correct time zone inside config.php, echo correctly in php. I get correct timestamp when echo in php and using tracy debugger console. However, the time stored for creation, modified, changelog are all using Unix Timestamp, i.e. UTC, while my correct time should be UTC+8. What is the possible config having this behavior?
  10. I would like to save very long string to a text field. My case is that I am saving canvas serialized data into text field for saving as state. However, the the text link cannot excceed certain length which is around 66535 something even though I set the field's max length as 0. What I can do to release the limit? Thanks.
  11. Thanks for this wonderful module. When SVG is used in image field, the download button is not appearing. I hope it can be there.
  12. Sorry this is my own fault. The issue arouse because I have written a hook to 'login', editing some pages that do not exist in new account.
  13. register ajax code $email = $sanitizer->email($input->post->email); if($email){ $emailUser = $users->get("email=$email"); if (!$emailUser->id) { $password = $input->post->password; if (strlen($_POST["password"]) < 8) { return "length"; } $firstname = $sanitizer->text($input->post->firstname); $lastname = $sanitizer->text($input->post->lastname); $u = new User(); $u->name = $firstname.$lastname.uniqid(); $u->email = $email; $u->pass = $input->post->password; $u->firstName = $firstname; $u->lastName = $lastname; if($u->save()){ return "success"; } } else { return "duplicate"; } }else{ return "invalidemail"; } login ajax code $email = $sanitizer->email($input->post->email); if($email){ $emailUser = $users->get("email=$email"); //user login with email address if ($emailUser->id) { $u = $session->login($emailUser->name, $input->post->password); if ($u) { $user = $u; return "success"; } else { return "fail"; } } else { return "fail"; } } After users register an account and login with the above code, I get the follow error when executing the login ajax code. Notice: Trying to get property of non-object in /var/app/current/wire/core/PagesEditor.php on line 251 Notice: Trying to get property of non-object in /var/app/current/wire/core/PagesEditor.php on line 254 Notice: Trying to get property of non-object in /var/app/current/wire/core/PagesEditor.php on line 263 Notice: Trying to get property of non-object in /var/app/current/site/assets/cache/FileCompiler/site/modules/ProcessSetupPageName/ProcessSetupPageName.module on line 258 Notice: Trying to get property of non-object in /var/app/current/site/assets/cache/FileCompiler/site/modules/ProcessSetupPageName/ProcessSetupPageName.module on line 258 Notice: Trying to get property of non-object in /var/app/current/site/assets/cache/FileCompiler/site/modules/ProcessSetupPageName/ProcessSetupPageName.module on line 289 Fatal error: Uncaught Error: Call to a member function numChildren() on null in /var/app/current/wire/core/PagesEditor.php:270 Stack trace: #0 /var/app/current/wire/core/Pages.php(788): ProcessWire\PagesEditor->setupNew(Object(ProcessWire\NullPage)) #1 /var/app/current/wire/core/Wire.php(383): ProcessWire\Pages->___setupNew(Object(ProcessWire\NullPage)) #2 /var/app/current/wire/core/WireHooks.php(698): ProcessWire\Wire->_callMethod('___setupNew', Array) #3 /var/app/current/wire/core/Wire.php(442): ProcessWire\WireHooks->runHooks(Object(ProcessWire\Pages), 'setupNew', Array) #4 /var/app/current/wire/core/PagesEditor.php(465): ProcessWire\Wire->__call('setupNew', Array) #5 /var/app/current/wire/core/Pages.php(410): ProcessWire\PagesEditor->save(Object(ProcessWire\NullPage), Array) #6 /var/app/current/wire/core/Wire.php(386): ProcessWire\Pages->___save(Object(ProcessWire\NullPage), Array) #7 /var/app/current/wire/core/WireHooks.php(698): ProcessWire\Wire->_callMethod('___save', Array) #8 /var/app/current/wire/core/Wire.php(4 in /var/app/current/wire/core/PagesEditor.php on line 270 Error: Uncaught Error: Call to a member function numChildren() on null in /var/app/current/wire/core/PagesEditor.php:270 I have no idea why this is happening. The account is newly created from the register code with no error. After the error show, the account is actually logged in after a page reload. That means the $session->login is getting the correct arguments. The error messages do not show the exact line of code which fires the error. I use the same login to log in my superuser without error. The error occurs only when the user is newly created by the above code or by the admin panel. I can only find this similar case https://processwire.com/talk/topic/15204-cannot-login-errors-wirecorepageseditorphp/, but it seems not the same case. Any thoughts? Thanks in advance.
  14. I have made a pull request. You may take the changes for use before the module update. Code changes to support ListerPro
  15. Thanks @arjen again for the reference links. If I could fix this I would post the fix here. This module is best suit for my new project but it just lacks the ListerPro support.