Jump to content

PWaddict

Members
  • Posts

    998
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by PWaddict

  1. The "Live Search" field is messed up. It displays many parts of .phrase-index.txt language's file as text. On Chrome console I'm getting the error: Uncaught SyntaxError: Invalid or unexpected token. How to fix this? Here is small part of it:
  2. And with this I can change the "Move to Trash" button's text: $this->wire()->addHookBefore('InputfieldButton::render', function($e) { if ($e->object->id != "submit_delete") return; if ($this->wire('user')->isSuperuser() == false) $e->object->value = "Hello World"; }); Thank you @kixe
  3. I figured it out: $wire->addHook('LazyCron::every4Weeks', function() { $trashed_pages = wire('pages')->find("parent=/trash/, include=all"); if(count($trashed_pages)) { wire('pages')->emptyTrash(); } }); Should I use the above or just the below simpler version? $wire->addHook('LazyCron::every4Weeks', function() { wire('pages')->emptyTrash(); });
  4. I'm trying to empty the trash with a hook but it's not working: $wire->addHook('LazyCron::everyMinute', function() { $trashed_pages = wire('pages')->find("parent=/trash/, include=all"); if(count($trashed_pages)) { $trashed_pages->emptyTrash(); } });
  5. I would like to change the "Move to Trash" text from the Delete tab only for non-superusers. Any ideas how to do that?
  6. Maybe this the hook ProcessPageView::pageNotFound you need.
  7. No need for alt 404 template. if($page->isUnpublished() && !$user->isSuperuser()) { $error404 = $pages->get(27); // ID of 404 page $session->redirect($error404->url, false); // 302 temporary redirect }
  8. I had to create an alternate template for 404 page and now it works: if($page->isUnpublished() && !$user->isSuperuser()) { $error404 = $pages->get("template=404-alt, include=hidden"); $session->redirect($error404->url, false); } If you know a better way let me know. Thanks.
  9. I've also tried this but isn't working. I'm getting a blank white page. if($page->isUnpublished() && !$user->isSuperuser()) { $error404 = $pages->get("template=404, include=hidden"); $session->redirect($error404->url, false); }
  10. Guests can't view them. I was talking about the site editors (non-superusers). I've already tried that but something isn't right. The site editor can see a 404 page (which is what I want) but lot of pw related content is hidden like titles, other fields content etc.
  11. PW by default allows non-superusers to view unpublished pages on frontend. Is there an option somewhere to prevent that?
  12. I solved it ? $client = $roles->get('client'); $s_template = $templates->get("my-template"); if ($page->my_checkbox) { if ($client->hasPermission('my-permission')) { $client->of(false); $client->removePermission('my-permission'); $client->save(); $s_template->revokePermissionByRole("page-add", $client); $s_template->save(); } } else { if (!$client->hasPermission('my-permission')) { $client->of(false); $client->addPermission('my-permission'); $client->save(); $s_template->addPermissionByRole("page-add", $client); $s_template->save(); } }
  13. Here is the first part for simply removing/adding a permission from specific role: $client = $roles->get('client'); if ($page->my_checkbox) { if ($client->hasPermission('my-permission')) { $client->of(false); $client->removePermission('my-permission'); $client->save(); } } else { if (!$client->hasPermission('my-permission')) { $client->of(false); $client->addPermission('my-permission'); $client->save(); } } @Zeka What I don't understand is how to remove permission "page-add" from template "my-template" from role "client".
  14. Here is what I want to do: if ($page->my_checkbox) { //Remove permission "my-permission" from role "client" //Remove permission "page-add" from template "my-template" from role "client" } else { //Add permission "my-permission" on role "client" //Add permission "page-add" on template "my-template" on role "client" } I would really appreciate your help.
  15. Done ? $css = '.PageListStatusUnpublished .PageListActionSelect, '; $css .= '.PageListStatusHidden .PageListActionSelect, '; $css .= '.PageListID7, '; // Hides the Trash page
  16. @Robin S The Trash page itself is selectable but I fixed it by adding .PageListStatusHidden in the hook so now non-superusers can't select the Trash page itself or any other hidden page: $css = '.PageListStatusUnpublished .PageListActionSelect, '; $css .= '.PageListStatusHidden .PageListActionSelect, '; Now only 1 issue remains. The pages inside Trash are selectable.
  17. @Robin S How to prevent selection of Trash page and unpublished pages?
  18. I copied your code again and now it works.
  19. I tried your second hook and I'm getting the following errors: Notice: Undefined variable: template in C:\xampp\htdocs\mysite\site\ready.php on line 131 Notice: Trying to get property of non-object in C:\xampp\htdocs\mysite\site\ready.php on line 131
  20. I've updated PW to 3.0.118 on localhost and this is what I see in the admin login screen:
  21. That result in a 500 server error. I changed it to the following and now I'm getting the proper time on backend's creation, modification, installation times etc. $config->dbInitCommand = "SET NAMES '{charset}', time_zone = '+02:00' "; Your DatetimeAdvanced module helped me with that ?
  22. According to the following @ryan post from 2013 the info field is not affected by the timezone.
  23. I tried date_default_timezone_set('Europe/Athens'); but still on the backend when a page is getting saved it says 6 hours ago on the "last modified".
  24. Nope. Already tried that. Timezone and locale are different things.
  25. I have 1 server in Canada and multiple client's pw websites from different countries hosted on that server. How can I set on each website to have client's correct timezone? I thought $config->timezone in site/config.php should do that but it doesn't. For example 1 website is from a client in Greece so I'm using this: $config->timezone = 'Europe/Athens'; but when a page is getting saved on the "last modified" info says 6 hours ago. That's the hour difference between Greece and Canada.
×
×
  • Create New...