-
Posts
908 -
Joined
-
Last visited
-
Days Won
1
Posts posted by PWaddict
-
-
30 minutes ago, ceberlin said:
I could not figure out yet which module or string creates the problem, but it seems to be some module I use a lot, as the problem appears on many sites.
It's very easy to find out which module causing this. Just search the module files if </body> and/or </script> closing tags are inside translatable strings.
-
@blynx Can you please add multi-language support on the "yt_hl" field (YouTube: Interface Language)?
-
I figured why is this happening. Now waiting for a response on how to proceed. For more info check the GitHub issue.
- 3
-
-
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
- 2
-
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(); } });
-
I would like to change the "Move to Trash" text from the Delete tab only for non-superusers. Any ideas how to do that?
-
Maybe this the hook ProcessPageView::pageNotFound you need.
- 2
-
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 }
-
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.
-
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); }
-
6 minutes ago, Tom. said:
I never knew that, I wonder why guests have permissions to view unpublished pages?
Guests can't view them. I was talking about the site editors (non-superusers).
7 minutes ago, Tom. said:if($page->isUnpublished() && !$user->isSuperuser()) throw new Wire404Exception();
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.
-
PW by default allows non-superusers to view unpublished pages on frontend. Is there an option somewhere to prevent that?
-
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(); } }
- 2
-
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".
- 1
-
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.
-
Done ?
$css = '.PageListStatusUnpublished .PageListActionSelect, '; $css .= '.PageListStatusHidden .PageListActionSelect, '; $css .= '.PageListID7, '; // Hides the Trash page
- 1
-
@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.
-
@Robin S How to prevent selection of Trash page and unpublished pages?
-
7 minutes ago, Robin S said:
My guess is that some non-printable character got pasted inside your code.
I copied your code again and now it works.
- 1
-
On 11/5/2018 at 12:09 AM, Robin S said:
In the meantime here are a couple of workaround hooks for /site/ready.php:
// ProcessPageEditLink > Link to URL: exclude pages using templates without template file $wire->addHookBefore('InputfieldPageAutocomplete(name=link_page_url)::render', function(HookEvent $event) { $inputfield = $event->object; $fileless_templates = []; foreach($this->wire()->templates as $template) { if(!$template->filenameExists()) $fileless_templates[] = $template->id; } $inputfield->findPagesSelector .= ', template!=' . implode('|', $fileless_templates); }); // ProcessPageEditLink > Select Page / Select Child Page: prevent selection of pages using templates without template file $wire->addHookAfter('ProcessPageEditLink::execute', function(HookEvent $event) { $css = ''; foreach($this->wire()->templates as $template) { if(!$template->filenameExists()) $css .= ".PageListTemplate_{$template->name} .PageListActionSelect, "; } if($css) { $css = rtrim($css, ', '); $css .= ' { display:none !important; }'; $event->return = $event->return . "<style>$css</style>"; } });
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 -
-
9 hours ago, BitPoet said:
What happens if you set the following in site/config.php:
$config->dbInitCommand = "SET NAMES '{charset}', time_zone='Europe/Athens'";
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 ?
- 7
"Live Search" is messed up
in Multi-Language Support
Posted
You need to go to your language id folder in site/assets/ and delete the .phrase-index.txt file.
I don't think so. The issue is still opened and @ryan will be notified.