Jump to content

horst

PW-Moderators
  • Content Count

    3,705
  • Joined

  • Last visited

  • Days Won

    78

horst last won the day on May 19

horst had the most liked content!

Community Reputation

5,306 Excellent

About horst

  • Rank
    observer of the big picture
  • Birthday 11/05/1955

Contact Methods

  • Website URL
    https://nogajski.de/

Profile Information

  • Gender
    Male
  • Location
    Aachen, Germany
  • Interests
    Photography; PHP, HTML, CSS (SASS,LESS), JS;

Recent Profile Visitors

34,007 profile views
  1. horst

    WireMailSmtp

    To be honest: I don't know. I don't know why you have this, and I don't know how to change this. ๐Ÿ˜ž
  2. I think in its basic it can be something like https://www.php.net/manual/en/class.splobserver.php ?
  3. Yep, too much freedom can be a big burden. ๐Ÿ™‚
  4. The "processwirish way", IMO, is called hooking. Therefore the originals modules author need to add three underscores to a method name: "___myMethodName()". This method than can be hooked and its output changed. Joshua, if you would add three underscores to the public render() method, I think its all done. @The G then should be able to hook in (before or after) and changes the output the way he likes to. In this case it seems like a small autoloaded custom module should fit: class MyCustomModule extends WireData implements Module { public static function getModuleInfo() { return [ 'title' => "MyCustomModule", 'summary' => "Customizes the output of PrivacyWire module", 'version' => "0.0.1", 'autoload' => true, 'singular' => true, 'requires' => [ "PrivacyWire", "PHP>=7.2", "ProcessWire>=3.0.0" ], 'icon' => 'cookie' ]; } public function ready() { $this->addHookBefore('PrivacyWire::render', $this, 'customRender'); } public function customRender(HookEvent $event) { // do your changes or complete override here // ... $myCustomOutput = $this->myHelperMethod(); $event->return = $myCustomOutput; } protected function myHelperMethod() { return 'something'; } } Not tested and I'm currently not perfect sure if its better to hook in before or after. (I think before, but you need to test it) TL;DR Other scenarios may be that the original modules author adds special hooking methods where an output finally is passed through. This function then optionally can be used for changes. // in PrivacyWire public function render(HookEvent $event) { ... $output = 'something'; $output = $this->finalizeOutput($output, $event); $event->return = $output; } public function ___finalizeOutput($output, $origEvent) { return str_replace("</body>", "{$output}</body>", $origEvent->return); } // in another module or site/ready.php, addHookAfter PrivacyWire::finalizeOutput
  5. If you need redirecting to the final domain name, you may have a look to this snippet. But you have to add it manually somewhere in the top of your root .htaccess file. ################################################################################ # Domain-Namen erzwingen # <IfModule mod_rewrite.c> RewriteEngine On AddDefaultCharset UTF-8 RewriteCond %{HTTP_HOST} ^example\.com [OR] RewriteCond %{HTTP_HOST} ^example-variation\.com [OR] RewriteCond %{HTTP_HOST} ^www\.example-variation\.com RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301] RewriteCond %{HTTPS} !=on RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] </IfModule> # ################################################################################
  6. @teppo You already got setup by Kixe and Robin. So, only thing that I can contribute is, if you are using this in an environment that allows overwriting existing files with same filename, you should bind a check of last modified timestamps into your program logic: If fileFieldItem is image and not thumbnail exists: create a thumbnail If fileFieldItem is image and not thumbnail exists OR if origTimestamp is newer than thumbnailTimestamp: create a (new) thumbnail
  7. I think you have to hook into Page::viewable, then detect if user has role reviewer and page is unpublished. If yes, you can change the return to true. Please search for hook examples with Page::viewable here in the forums. There will be some available. Or you look into existing modules how it is done there, like this one: https://github.com/Sebiworld/PageAccessReleasetime/blob/master/PageAccessReleasetime.module.php#L182-L201 and here https://github.com/Sebiworld/PageAccessReleasetime/blob/master/PageAccessReleasetime.module.php#L241-L254 And you don't need to build a module, you can write the hook into the site/ready.php file.
  8. @Tyssen sent you a PM.
  9. I have understand right, there is only one image field in use in how many pages, ca.? Maybe best bet would be also to create a test template with a new image field of type cai3, create a page and test things out. If this does work but the old one not, this would be good. If the new created one will not work too, this would be a greater disaster, I believe. On a side note: file access rights for image variations are correct? I have to leave office now for some hours, but will come back later here.
  10. There are different ways described in the thread how to upgrade from previous version. PW-versions and the Crop-modules! Have you followed them? Which was the origin PW version? Wich Crop modules was installed and used in the origin version? How have you updated the module, the user roles, the image fields? Without that information, it is hard to tell anything useful.
  11. I played around with multi-instances and found out that we currently (PW 3.0.163) are not able to use multiple instances when more then one site has set $config->useFunctionsAPI (in site/config.php) to true! Then I saw that, (when $config->useFunctionsAPI was set to false) in all instances $config->version returned the same version, that from the master instance. So, first I was a bit confused, but then I thought that this may have to do with the early step when PW processes/build the $config. And indeed, if I set in all site/config.php files the $config->useFunctionsAPI to false, and then in all site/init.php files to true, everything is working fine. Now we can use our sites with the functions API, and we can load as many multiple instances in parallel we want. ๐Ÿ™‚ TL;DR site/init.php /** * FOR BETTER SUPPORT OF MULTIINSTANCES, WE ENABLE $config->useFunctionsAPI HERE, * INSTEAD OF THE site/config.php FILE: */ $wire->config->useFunctionsAPI = true; Bootstrapping three different instances, in first step each of them in a single environment: <?php namespace ProcessWire; if(!defined('PW_MASTER_PATH')) define('PW_MASTER_PATH', 'E:/laragon/www/hwm/'); if(!defined('PW_MASTER_HTTPURL')) define('PW_MASTER_HTTPURL', 'https://hwm.local/'); // bootstrap ProcessWire instance site1 (3.0.163) require_once(PW_MASTER_PATH . 'index.php'); mvd([ 'httpurl' => $wire->wire('pages')->get(1)->httpURL, 'instanceNum' => $wire->getInstanceNum(), 'config->version' => $wire->wire('config')->version, 'useFunctionsAPI' => $wire->wire('config')->useFunctionsAPI ]); When running all three in a multi instance environment, they load fine, (no compile error), all with the use for the functions API enabled: <?php namespace ProcessWire; if(!defined('PW_MASTER_PATH')) define('PW_MASTER_PATH', 'E:/laragon/www/hwm/'); if(!defined('PW_MASTER_HTTPURL')) define('PW_MASTER_HTTPURL', 'https://hwm.local/'); if(!defined('PW_SITE2_PATH')) define('PW_SITE2_PATH', 'E:/laragon/www/hwm2/'); if(!defined('PW_SITE2_HTTPURL')) define('PW_SITE2_HTTPURL', 'https://hwm2.local/'); if(!defined('PW_SITE3_PATH')) define('PW_SITE3_PATH', 'E:/laragon/www/hwm3/'); if(!defined('PW_SITE3_HTTPURL')) define('PW_SITE3_HTTPURL', 'https://hwm3.local/'); // bootstrap ProcessWire master instance (3.0.163) require_once(PW_MASTER_PATH . 'index.php'); mvd([ 'httpurl' => $wire->wire('pages')->get(1)->httpURL, 'instanceNum' => $wire->getInstanceNum(), 'config->version' => $wire->wire('config')->version, 'useFunctionsAPI' => $wire->wire('config')->useFunctionsAPI ]); // create a secondary instance from master (3.0.163) $wire = new \ProcessWire\ProcessWire(PW_MASTER_PATH); mvd([ 'httpurl' => $wire->wire('pages')->get(1)->httpURL, 'instanceNum' => $wire->getInstanceNum(), 'config->version' => $wire->wire('config')->version, 'useFunctionsAPI' => $wire->wire('config')->useFunctionsAPI ]); // create instance of a second site (3.0.162) $site2 = new ProcessWire(PW_SITE2_PATH, PW_SITE2_HTTPURL); mvd([ 'httpurl' => $site2->wire('pages')->get(1)->httpURL, 'instanceNum' => $site2->getInstanceNum(), 'config->version' => $site2->wire('config')->version, 'useFunctionsAPI' => $site2->wire('config')->useFunctionsAPI ]); // create instance of a third site (3.0.152) $site3 = new ProcessWire(PW_SITE3_PATH, PW_SITE3_HTTPURL); mvd([ 'httpurl' => $site3->wire('pages')->get(1)->httpURL, 'instanceNum' => $site3->getInstanceNum(), 'config->version' => $site3->wire('config')->version, 'useFunctionsAPI' => $site3->wire('config')->useFunctionsAPI ]);
  12. In this post (https://processwire.com/docs/start/api-access/) Ryan says So, this has made me thinking it should be. Also I tried setting it on the fly to false before creating the second instance. But I had not verified that it was definetly disabled. Now after writing it into all site/config.php files, the error is gone and I get multiple instances. But I encountered a new weird thing: I loaded three instances with the PW versions 3.162 + 3.0.160 + 3.0.155. But when executing this code, every instance shows me the 162 !! ?? ๐Ÿ˜• // bootstrap ProcessWire master instance require_once(PW_MASTER_PATH . 'index.php'); mvd($wire->getInstanceNum() .' # '. $wire->config->version); // echo instance and version of the master (expected: 3.0.162) $wire = new \ProcessWire\ProcessWire(PW_MASTER_PATH); mvd($wire->getInstanceNum() .' # '. $wire->config->version); // echo instance and version of the new created instance from master (expected: 3.0.162) $site2 = new ProcessWire(PW_SITE2_PATH, PW_SITE2_HTTPURL); mvd($site2->getInstanceNum() .' # '. $site2->config->version); // echo instance and version of site2 (expected: 3.0.160) $site3 = new ProcessWire(PW_SITE3_PATH, PW_SITE3_HTTPURL); mvd($site3->getInstanceNum() .' # '. $site3->config->version); // echo instance and version of site3 (expected: 3.0.155) die('RIP');
  13. Hi all, I tried to run two instances of pw that resides in parallel directories of the same server. I've done like it was explained in a older blog post (around PW 3.0.32) and it throughs me a compile error, regardless if in web environment or on CLI. <?php namespace ProcessWire; if(!defined('PW_MASTER_PATH')) define('PW_MASTER_PATH', 'E:/laragon/www/pw1/'); // PW 3.0.162 if(!defined('PW_MASTER_HTTPURL')) define('PW_MASTER_HTTPURL', 'https://pw1.local/'); if(!defined('PW_SITE2_PATH')) define('PW_SITE2_PATH', 'E:/laragon/www/pw2/'); // PW 3.0.160 if(!defined('PW_SITE2_HTTPURL')) define('PW_SITE2_HTTPURL', 'https://pw2.local/'); // bootstrap ProcessWire master instance require_once(PW_MASTER_PATH . 'index.php'); // create a second instance $site = new ProcessWire(PW_SITE2_PATH, PW_SITE2_HTTPURL); // or: new ProcessWire(PW_SITE2_PATH); The error is: Compile Error: Cannot redeclare pages() (previously declared in E:\__PW-DISTRIS\wire-3.0.162\core\FunctionsAPI.php:63) (line 63 of E:\__PW-DISTRIS\wire-3.0.160\core\FunctionsAPI.php) So, is there a newer / other way nowadays to create a second instance?
  14. But is the parent page there in your target system? If not, would you mind to simply create it first? Otherwise I don't get what you are asking for.
  15. Don't know this feature, but whats about: different PHP versions local and online? (or: different PHP extensions local and online?, that may be invoked by processing a base32 string.)
ร—
ร—
  • Create New...