-
Posts
998 -
Joined
-
Last visited
-
Days Won
3
Everything posted by PWaddict
-
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:
-
[SOLVED] How to modify "Move to Trash" only for non-superusers?
PWaddict replied to PWaddict's topic in General Support
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 -
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(); });
-
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(); } });
-
Maybe this the hook ProcessPageView::pageNotFound you need.
- 4 replies
-
- 2
-
-
- 404
- pagenotfound
-
(and 1 more)
Tagged with:
-
[SOLVED] How to Add/Remove permissions via API?
PWaddict replied to PWaddict's topic in API & Templates
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(); } } -
[SOLVED] How to Add/Remove permissions via API?
PWaddict replied to PWaddict's topic in API & Templates
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". -
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.
-
CKE pwlink: pages without templates shouldn't be selectable
PWaddict replied to Klenkes's topic in General Support
Done ? $css = '.PageListStatusUnpublished .PageListActionSelect, '; $css .= '.PageListStatusHidden .PageListActionSelect, '; $css .= '.PageListID7, '; // Hides the Trash page -
CKE pwlink: pages without templates shouldn't be selectable
PWaddict replied to Klenkes's topic in General Support
@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. -
CKE pwlink: pages without templates shouldn't be selectable
PWaddict replied to Klenkes's topic in General Support
@Robin S How to prevent selection of Trash page and unpublished pages? -
CKE pwlink: pages without templates shouldn't be selectable
PWaddict replied to Klenkes's topic in General Support
I copied your code again and now it works. -
CKE pwlink: pages without templates shouldn't be selectable
PWaddict replied to Klenkes's topic in General Support
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 -
-
[SOLVED] How to set database timezone on Shared Servers?
PWaddict replied to PWaddict's topic in General Support
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 ? -
[SOLVED] How to set database timezone on Shared Servers?
PWaddict replied to PWaddict's topic in General Support
According to the following @ryan post from 2013 the info field is not affected by the timezone. -
[SOLVED] How to set database timezone on Shared Servers?
PWaddict replied to PWaddict's topic in General Support
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". -
[SOLVED] How to set database timezone on Shared Servers?
PWaddict replied to PWaddict's topic in General Support
Nope. Already tried that. Timezone and locale are different things. -
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.