Jump to content

PWaddict

Members
  • Posts

    908
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by PWaddict

  1. 2 hours ago, ceberlin said:

    How do I reset the translation cache to test the effect of their removal?

    You need to go to your language id folder in site/assets/ and delete the .phrase-index.txt file.

    37 minutes ago, ceberlin said:

    Github does not seem to bring the (2y old) topic back to the top just because of new entries. The issue might be overlooked?

    I don't think so. The issue is still opened and @ryan will be notified.

    • Thanks 1
  2. 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.

  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. 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.

  6. 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();
    
    	}
    }

     

    • Like 2
  7. 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".

    • Like 1
  8. 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.

  9. 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

  10. 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 ?

    • Like 7
×
×
  • Create New...