Jump to content
joshua

PrivacyWire - Cookie Management & async external asset loading

Recommended Posts

Hello,

I tried to uninstall this module so I could test another, but I'm getting this error after uninstalling it. Based on what this error seems to be indicating, I made sure that I uninstalled TextformatterPrivacyWire first, before uninstalling PrivacyWire. But that didn't work either. Is there something else that I should be doing? I thought it might be ProCache, but I turned that off too.

Please let me know. Thank you!

Error: Exception: Module TextformatterPrivacyWire requires: PrivacyWire>=0.0.5 (in /usr/home/jc/public_html/test.com/wire/core/Modules.php line 1857
#0 /usr/home/jc/public_html/test.com/wire/core/Wire.php(383): ProcessWire\Modules->___install('TextformatterPr...')
#1 /usr/home/jc/public_html/test.com/wire/core/WireHooks.php(823): ProcessWire\Wire->_callMethod('___install', Array)
#2 /usr/home/jc/public_html/test.com/wire/core/Wire.php(450): ProcessWire\WireHooks->runHooks(Object(ProcessWire\Modules), 'install', Array)
#3 /usr/home/jc/public_html/test.com/wire/core/Modules.php(1303): ProcessWire\Wire->__call('install', Array)
#4 /usr/home/jc/public_html/test.com/wire/core/Modules.php(1194): ProcessWire\Modules->getModule('TextformatterPr...')
#5 /usr/home/jc/public_html/test.com/wire/modules/Fieldtype/FieldtypeText.module(97): ProcessWire\Modules->get('TextformatterPr...')


This error message was shown because: you are logged in as a Superuser. Error has been logged.

 

 

Share this post


Link to post
Share on other sites
19 hours ago, montero4 said:

Hello,

I tried to uninstall this module so I could test another, but I'm getting this error after uninstalling it.

Hi Montero,

thank you for your feedback. I just looked into this and fixed the bug in the new release.

Best,
Joshua

Share this post


Link to post
Share on other sites
On 5/30/2020 at 5:06 PM, ceberlin said:

Isn't it required in the new word of EU web bureaucracy to list every single cookie on demand (by category) and explain what is does, where it's from and can set it individually?

So, for example, in the same example category "my user settings" I can agree to remember a "my selected language" cookie but not another cookie with "my last page visited"?

As Borlabs cookie does it, or Klaro (kind of)?

Am I wrong with my understanding of the current GDPR law situation? Or is this implemented already and I just did not find it?

(Right now I am evaluation this module against using KLARO directy)

That's an interesting point. As I understood the GDPR (but I'm not a lawyer, so not sure about that) a listing of the single cookies is not mandatory right now - but the upcoming ePrivacy could change that.

When you want/need to implement this solution, KLARO could be a better choice at the moment. Currently this feature isn't included in PrivacyWire and I'm not sure if or when I could implement it. Or you could fork PrivacyWire and add the feature with a PR? 😉

Best,
Joshua

  • Like 1

Share this post


Link to post
Share on other sites

Hi Joshua, yes, in Germany, this is not mandatory at the moment - in other EU countries the situation might be different. All German lawyers online with lots of drama about the subject offer - surprise surprise - their own commercial solutions. I have not read any neutral position/comment on the subject yet. As I understand it, the tenor from the BGH is that the user should be able to know exactly what he or she agrees to. According to this, the webdesigner would have to name names.

The BGH ruling is still too recent (end of May 2020) and has not yet been implemented in German law. I just want to be prepared. I am irritated to I see the free KLARO goes the same route, listing all the little details.

I am not prepared yet to fork and PR. I am thinking about possible concepts right now. Maybe just adding an optional data-attribute with some line of text or a link which is is dispayed with a "read more" in the module's output, so the module does not need to handle every little detail? I am curious about other opinions from EU developers here. (I am also checking out the KARO module for WordPress right now to see how they are managing the information there.)

Cheers, Carl

  • Like 1

Share this post


Link to post
Share on other sites

Joshua, first, thank you for all your work. It looks like that we need a good solution for compliance also in Germany now (after the BGH ruling) and I am glad, that your plugin is close to what we need already.

After comparing existing tools and reading more about the requirements I thought of the following strategy to add to the compliance:
(My source of information: https://www.activemind.de/magazin/cookie-consent-banner/)

1. we probably need another category.

"Functional" for settings that are not "essential", like settings, example use: remember that a certain popup was closed. Comes after "essential" (or better the order of the selected categories from the backend is remembered)

2. Details collection.

This info should to be collected: name of cookie, issuer, purpose, functions, privacy links. Example:
name: '_ga, _gid',
issuer: 'Google Universal Analytics',
purpose: 'Collect statistical data for service improvement.',
functions: 'Number of pageviews, link clicked etc. ',
privacyLink: 'https://policies.google.com/privacy?hl=en'

Some vendors like cookiebot overload their popup with information. I think this confuses more than it helps. Setting content should not be rocket science to average users.

Instead, I thought of having the details on a special (manually filled?) compliance page, sorted into category blocks. That means that means another optional link (next to imprint and privacy) in the settings could be useful.

If this strategy makes sense, then it would be fancy if your textformatter could handle the consent from there: [[privacywire-category-settings category="statistics" ]] and display a toggle for on/off for that category. (But this has no priority)

3. Styles / Popup responsive? 

Right now the popup is not working correctly on mobile phones. It is not scrollable, and with lots of description and selections it easily has more content than fitting on a small screen.

  • We need another wrapper div tag for the element and another wrapper div tag with a class for the links - and add classes to all elements like the lists - so this is easier to style.
  • Also the body text is maybe not needed right away so there should be an option in the backend to display that only on the page which opens, when "select" is choosen?
  • Maybe add a field in the backend to drop all the CSS so it is easy to maintain at one place?

4. External media.

Can you explain what happens in that case? How can your code handle iframes, e.g. YouTube, Vimeo and maps? What happens if one of the existing video plugins are used?

5. Cookie lifetime of this plugin max 7 days?

In Safari and Firefox JavaScript cookies have a short lifetime, even if the cookie is set with a very long expiration date. A user has to opt-in again every 7 days. Is this correct? and is an alternative? Source: https://alightanalytics.com/alight-insights/safari-first-party-cookies/

---

Before a line of code is written, I would ask everyone for feedback and ideas for this concept...

---

By the way: here is a nice layout example with a consent banner with kind of your feature set - they also follow the route to move all complicated cookie details to a separate cookie consent page:

https://www.osano.com/cookieconsent/download/

 

 

  • Like 1

Share this post


Link to post
Share on other sites

Hi Joshua, the module works fine.
I would like to use the Textformatter to generate a button. [[privacywire-choose-cookies]]
But I don't get how to implement the shortcode.. 😬
In a Textfield? That doesnt work. Sorry for this noob-question.
Thank you!

Ok..now I got it!

Edited by Nick Belane
  • Like 1

Share this post


Link to post
Share on other sites

Hey,

great module. Good work! I think it would be nice for the user to implement explaining textfields for each cookie category and not only titles, because people might not know what they are accepting.

  • Like 1

Share this post


Link to post
Share on other sites

Hello gentlemen and thank you for your fine module, Joshua!

Is there a way to preserve the changes to the HTML/CSS of the banner after updates? Maybe there is a generic processwirish way to override module markup?

Right now I added a method to the module that allows me to replace the module's markup by placing the modified files in /site/templates/MODULE_DIR/:

    protected function getFile($file, $is_url = false)
    {
        // we're putting module overrides in /site/templates/modules
        $override_dir = 'modules/' . basename(dirname(__FILE__)) .'/';
        $override_path = $this->wire('config')->paths->templates . $override_dir . $file;
        // we're overriding files in the module's folder
        $default_path = $this->wire('config')->paths->$this . $file;

        if (is_readable($override_path)) {
            return $is_url ? $this->wire('config')->urls->templates . $override_dir . $file : $override_path;
        }

        return $is_url ? $this->wire('config')->urls->$this . $file : $default_path;
    }

and using it like this:

$jsFilePath = $this->getFile('js/PrivacyWire.js', true);

and

$output = wireRenderFile($this->getFile('PrivacyWireBanner.php'), [ 'module' => $this ]);

 

This way I only have to add the above code into the module after the update, while keeping my changes in /site/templates/PrivacyWire/, to preserve the look of the banner, from the default

2020-08-06-131451.png.9b206751af206c4b215924363de9db59.png

to a Bulma version

2020-08-06-131529.png.a7a7c169547ec401c8301ee8f7ab5159.png

  • Like 2

Share this post


Link to post
Share on other sites

Thank you for all your input! I've been quite busy the last weeks, sorry for my delay in answering your requests.
During the last couple of days I refactored some code and implemented an suggested feature by @horst (to call a custom js function after saving the consent). As this version might not be as stable as the current version, you'll find it currently in a separate branch. The following updates are also only in this branch at the moment.

On 6/2/2020 at 11:10 AM, ceberlin said:

1. we probably need another category.

"Functional" for settings that are not "essential", like settings, example use: remember that a certain popup was closed. Comes after "essential" (or better the order of the selected categories from the backend is remembered)

I agree on that and just added this category to PrivacyWire (in the V2-Branch).

On 6/2/2020 at 11:10 AM, ceberlin said:

5. Cookie lifetime of this plugin max 7 days?

In the new branch I switched to save the consent information in LocalStorage instead of Cookies. Now the lifetime in all browsers should be 365 days.

About the details about cookies / categories: I also agree that there should be an option to display more details. The idea of a Textformatter for this purpose sounds good. Haven't got the time though to implement it right away. I'm open for PullRequests with improvements, if you want 😉

The styling is currently applied directly within the js file. To add the option to disable loading the stylesheet, I could exclude this from the js file and add an option to the module config.

  • Like 1

Share this post


Link to post
Share on other sites
23 hours ago, The G said:

Is there a way to preserve the changes to the HTML/CSS of the banner after updates? Maybe there is a generic processwirish way to override module markup?

Good question! I don't know a native "processwirish" procedure for this yet. Your solution like a good start. Does anyone else knows a processwirish way of doing this?

Share this post


Link to post
Share on other sites
2 hours ago, joshua said:

Good question! I don't know a native "processwirish" procedure for this yet. Your solution like a good start. Does anyone else knows a processwirish way of doing this?

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

 

  • Thanks 1

Share this post


Link to post
Share on other sites

Ah, but of course! How could I forget about hooks! Thank you, @horst! I realize now that I could probably keep all my overrides in a single place, depending on the presence of the hooks, of course.

@joshua, please make the render() function hookable.

Sometimes I wish ProcessWire could be more restrictive, my /site/ folder is a frankensteinish patchwork of code snippets, because I used whatever the search cat dragged in first 🤣

  • Like 2

Share this post


Link to post
Share on other sites
20 minutes ago, The G said:

Sometimes I wish ProcessWire could be more restrictive

Yep, too much freedom can be a big burden. 🙂

  • Like 1

Share this post


Link to post
Share on other sites

I 've done a pull request against the v2 branch, only three underscores added 😄

This is how I hooked it in ready.php (these are theme specific overrides, so I want to keep them in the /site/ folder somewhere):

// If I want to do something with front pages (old code)
//if (strpos($_SERVER['REQUEST_URI'], $config->urls->admin) !== 0) {
// my front pages are all extending a FrontPage class
// see https://processwire.com/blog/posts/pw-3.0.152/#new-ability-to-specify-custom-page-classes
if (is_subclass_of(page(), 'Processwire\FrontPage')) {
	// [...]

	$wire->addHookBefore('PrivacyWire::render', function($event) {
        $event->replace = true;
        $privacywire = $event->object;

        $isProCache = modules()->isInstalled('ProCache') && modules()->get('ProCache');
        $jsFilePath = getModuleFile($privacywire, 'js/PrivacyWire.js', true);
        if ($isProCache && $privacywire->use_procache_minification) {
            $jsFilePath = modules()->get('ProCache')->js($jsFilePath);
        }

        $output = wireRenderFile(getModuleFile($privacywire, 'PrivacyWireBanner.php'), [ 'module' => $privacywire ]);
        $output .= "\n<script>var PrivacyWireSettings={version:'{$privacywire->version}',dnt:'" . ((int) $privacywire->respectDNT) . "'};</script>";
        $output .= "\n<script defer src='{$jsFilePath}'></script>";

        $event->arguments(0)->return = str_replace("</body>", "{$output}</body>", $event->arguments(0)->return);
    });

	// [...]
}

/**
 * checks for a module file override in the path defined
 * @param  object  $module    the module needing a file overriden
 * @param  string  $file_path the override file path, from the module folder, i.e. "js/PrivacyWire.js"
 * @param  boolean $is_url    switch for outputting a path or an URL, by default the function outputs a path
 * @return string             the override path is it's readable or the initial file path if it's not
 */
function getModuleFile($module, $file_path, $is_url = false)
{
    // we're putting module overrides in /site/templates/modules/
    $override_dir = 'modules/' . $module->className() .'/';
    $override_path = paths()->templates . $override_dir . $file_path;
    // we're overriding files in the module's folder
    $default_path = paths()->$module . $file_path;

    if (is_readable($override_path)) {
        return $is_url
            ? urls()->templates . $override_dir . $file_path
            : $override_path;
    }

    return $is_url
        ? urls()->$module . $file_path
        : $default_path;
}

 

  • Like 2

Share this post


Link to post
Share on other sites

Thank you for the PR and the idea! Of course it's a good think to have the render function hookable. I also like the idea of @horst with an hookable output file. I would definitely like to spend some time soon to refactor / optimize PrivacyWire.

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

Just wanted to say thank you for this highly needed plugin! Is there a way to donate for it?

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites
3 hours ago, Matze said:

Just wanted to say thank you for this highly needed plugin! Is there a way to donate for it?

Thanks for your feedback - I'm glad you like it!
Haven't thought about a way for donation yet, but PayPal should work fine. Thanks a lot 🙂

Share this post


Link to post
Share on other sites

After the user saves his/her choices, a confirmation message is shown for 1.5 seconds, then is removed.

My contact page uses Google Recaptcha and thus it needs Google's marketing cookies to work. So, in the beginning, instead of the contact form, the page shows only a message explaining that if one wishes to use the contact form, one needs to consent to the marketing cookies. Only after/if the user consents is the form shown. I wanted to have the page refreshed after saving the choices, so the user would not need to do a manual refresh to see the changes. I did it by adding a

74 window.location.reload(true);

line after

73	priw_wrapper.classList.remove('show-message');

which is the one where the confirmation message is removed (priw_showMessage(), line 73 in src/js/PrivacyWire.js) and re-rollup-ing. I could make a pull request if it seems useful.

 

Another suggestion would be make the setTimeout delay configurable. This one is not something I needed, but it just feels right to have it configurable 😁

Share this post


Link to post
Share on other sites

Thanks for your input, @The G. There actually already is a way to solve this, thanks to the previous input from @horst:

In the PrivacyWire Settings you can find the "Trigger a custom js function" field:

grafik.png.57da220f8be9a170b45074a5f537e8d6.png

Just add a function name there, which you want to get triggered (in this examle the function is called reloadAfterConsent )
Then somewhere in your code add the relevant function, e.g.:

<script>
    var reloadAfterConsent = function() {
      window.location.reload(true);
    }
</script>

And voilá - your page reloads after every consent saving.

 

14 hours ago, The G said:

Another suggestion would be make the setTimeout delay configurable. This one is not something I needed, but it just feels right to have it configurable 😁

One could make this configurable, of course. Would you like to set the duration or something else of the setTimeout?

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

Nice, it works beautifully.

 

3 hours ago, joshua said:

[...] One could make this configurable, of course. Would you like to set the duration or something else of the setTimeout?

The duration. I'd like to let the user read the message for a little longer:
simplescreenrecorder-2020-09-24_11_45_40.gif.73d372e9619843b286b63fcae514b57d.gif

 

Off-topic question: how does one make posted videos to not extend to the full container width? I used the annoying GIF above because I didn't find a way to display posted videos at their real size.

 

Share this post


Link to post
Share on other sites
On 9/24/2020 at 11:39 AM, The G said:

The duration. I'd like to let the user read the message for a little longer:

The config option for this duration is now included in 0.2.3 😉

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites
On 5/10/2020 at 1:41 PM, joshua said:
On 4/9/2020 at 5:45 PM, DV-JF said:

Is there an opposite option to only show an element if a specific data-category isn't allowed?

That's a good point. Right now there isn't a detection for this but I'll think about a way to implement this.

Hey @joshua any news or ideas on this?

Share this post


Link to post
Share on other sites

Anyone else experiencing weird behaviour with the external_media option while opting in/out of it?

A recent project needed a little overhaul therefore external media is now only available after opting in to it BUT... it's not working out as expected after you later on decide to opt out or in to it.

Thought about issues with some custom JS but even on a clean install the issue occures.
It's not happening with any other option so far - so I could work around that issue for now.

As you can see the values in local storage are already off for external_media.

pw001.thumb.png.7f3127081d3c8a2dd2e699ae86e3c28e.png

pw002.thumb.png.0c8f0e1980e9459e15966ea8ce3b510f.png

 

  • Like 3

Share this post


Link to post
Share on other sites

Thank you for reporting this bug / weird behaviour @wbmnfktr!

I just looked into this topic and discovered two typos which have produced this buggy behaviour.
The new release 0.2.4 fixed this.

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By horst
      Wire Mail SMTP

      An extension to the (new) WireMail base class that uses SMTP-transport

      This module integrates EmailMessage, SMTP and SASL php-libraries from Manuel Lemos into ProcessWire. I use this continously evolved libraries for about 10 years now and there was never a reason or occasion not to do so. I use it nearly every day in my office for automated composing and sending personalized messages with attachments, requests for Disposition Notifications, etc. Also I have used it for sending personalized Bulkmails many times.

      The WireMailSmtp module extends the new email-related WireMail base class introduced in ProcessWire 2.4.1 (while this writing, the dev-branch only).
       
      Here are Ryans announcement.



      Current Version 0.6.0
      Changelog: https://github.com/horst-n/WireMailSmtp/blob/master/CHANGELOG.md
      get it from the Modules Directory Install and Configure

      Download the module into your site/modules/ directory and install it.

      In the config page you fill in settings for the SMTP server and optionaly the (default) sender, like email address, name and signature.
      You can test the smtp settings directly there. If it says "SUCCESS! SMTP settings appear to work correctly." you are ready to start using it in templates, modules or bootstrap scripts.


      Usage Examples
      The simplest way to use it:
      $numSent = wireMail($to, $from, $subject, $textBody); $numSent = wireMail($to, '', $subject, $textBody); // or with a default sender emailaddress on config page This will send a plain text message to each recipient.
       
      You may also use the object oriented style:
      $mail = wireMail(); // calling an empty wireMail() returns a wireMail object $mail->to($toEmail, $toName); $mail->from = $yourEmailaddress; // if you don't have set a default sender in config // or if you want to override that $mail->subject($subject); $mail->body($textBody); $numSent = $mail->send(); Or chained, like everywhere in ProcessWire:
      $mail = wireMail(); $numSent = $mail->to($toEmail)->subject($subject)->body($textBody)->send(); Additionaly to the basics there are more options available with WireMailSmtp. The main difference compared to the WireMail BaseClass is the sendSingle option. With it you can set only one To-Recipient but additional CC-Recipients.
      $mail = wireMail(); $mail->sendSingle(true)->to($toEmail, $toName)->cc(array('person1@example.com', 'person2@example.com', 'person3@example.com')); $numSent = $mail->subject($subject)->body($textBody)->send(); The same as function call with options array:
      $options = array( 'sendSingle' => true, 'cc' => array('person1@example.com', 'person2@example.com', 'person3@example.com') ); $numSent = wireMail($to, '', $subject, $textBody, $options); There are methods to your disposal to check if you have the right WireMail-Class and if the SMTP-settings are working:
      $mail = wireMail(); if($mail->className != 'WireMailSmtp') { // Uups, wrong WireMail-Class: do something to inform the user and quit echo "<p>Couldn't get the right WireMail-Module (WireMailSmtp). found: {$mail->className}</p>"; return; } if(!$mail->testConnection()) { // Connection not working: echo "<p>Couldn't connect to the SMTP server. Please check the {$mail->className} modules config settings!</p>"; return; }  
      A MORE ADVANCED DEBUG METHOD!
      You can add some debug code into a template file and call a page with it:
      $to = array('me@example.com'); $subject = 'Wiremail-SMTP Test ' . date('H:i:s') . ' äöü ÄÖÜ ß'; $mail = wireMail(); if($mail->className != 'WireMailSmtp') { echo "<p>Couldn't get the right WireMail-Module (WireMailSmtp). found: {$mail->className}</p>"; } else { $mail->from = '--INSERT YOUR SENDER ADDRESS HERE --'; // <--- !!!! $mail->to($to); $mail->subject($subject); $mail->sendSingle(true); $mail->body("Titel\n\ntext text TEXT text text\n"); $mail->bodyHTML("<h1>Titel</h1><p>text text <strong>TEXT</strong> text text</p>"); $dump = $mail->debugSend(1); } So, in short, instead of using $mail->send(), use $mail->debugSend(1) to get output on a frontend testpage.
      The output is PRE formatted and contains the areas: SETTINGS, RESULT, ERRORS and a complete debuglog of the server connection, like this one:
       
      Following are a ...


      List of all options and features


      testConnection () - returns true on success, false on failures


      sendSingle ( true | false ) - default is false

      sendBulk ( true | false ) - default is false, Set this to true if you have lots of recipients (50+)


      to ($recipients) - one emailaddress or array with multiple emailaddresses

      cc ($recipients) - only available with mode sendSingle, one emailaddress or array with multiple emailaddresses

      bcc ($recipients) - one emailaddress or array with multiple emailaddresses

       
      from = 'person@example.com' - emailaddress, can be set in module config (called Sender Emailaddress) but it can be overwritten here

      fromName = 'Name Surname' - optional, can be set in module config (called Sender Name) but it can be overwritten here


      priority (3) - 1 = Highest | 2 = High | 3 = Normal | 4 = Low | 5 = Lowest

      dispositionNotification () or notification () - request a Disposition Notification


      subject ($subject) - subject of the message

      body ($textBody) - use this one alone to create and send plainText emailmessages

      bodyHTML ($htmlBody) - use this to create a Multipart Alternative Emailmessage (containing a HTML-Part and a Plaintext-Part as fallback)

      addSignature ( true | false ) - the default-behave is selectable in config screen, this can be overridden here
      (only available if a signature is defined in the config screen)

      attachment ($filename, $alternativeBasename = "") - add attachment file, optionally alternative basename


      send () - send the message(s) and return number of successful sent messages


      debugSend(1) - returns and / or outputs a (pre formatted) dump that contains the areas: SETTINGS, RESULT, ERRORS and a complete debuglog of the server connection. (See above the example code under ADVANCED DEBUG METHOD for further instructions!)


      getResult () - returns a dump (array) with all recipients (to, cc, bcc) and settings you have selected with the message, the message subject and body, and lists of successfull addresses and failed addresses,


      logActivity ($logmessage) - you may log success if you want

      logError ($logmessage) - you may log warnings, too. - Errors are logged automaticaly
       
       
      useSentLog (true | false) - intended for usage with e.g. third party newsletter modules - tells the send() method to make usage of the sentLog-methods - the following three sentLog methods are hookable, e.g. if you don't want log into files you may provide your own storage, or add additional functionality here

      sentLogReset ()  - starts a new LogSession - Best usage would be interactively once when setting up a new Newsletter

      sentLogGet ()  - is called automaticly within the send() method - returns an array containing all previously used emailaddresses

      sentLogAdd ($emailaddress)  - is called automaticly within the send() method
      Changelog: https://github.com/horst-n/WireMailSmtp/blob/master/CHANGELOG.md
       
       
    • By Cybermano
      Food Allergens Module
      A simple List of Food Allergens
      My needs were to provide a simple list of food allergens for our clients with restaurant related activity.
      The idea was to simply output the list (to speed up the data entry) without leaving the food menu editing, eg. opening another page in new tab or window.
      This isn't a perfect solution, but it works fine for my needs and I decided to share the base idea.
      This could also be easily used to show little notes or short "vademecum", not only for the list of food allergens.
      ---
      Main features
      The basis
      All moves from a short editing of the module in this tutorial: How to create custom admin pages by @bernhard
      First of all it creates an empty admin page, with a dedicated permission to let safe-user to see it (this permission has to be created as a new ones, manually or by the module).
      Once the page is created, I have hooked its behaviour into the ready.php, to show the content (basically a list).
      A step further
      With the tips of  @bernhard, @Soma (and many others), see here , the magic happens. 
      The new page will be shown as a panel, so editors will not abandon their data entry to have a quick view to the list.
      A little further
      Why scroll to the top of the page to click a link?
      The next step was to create a sticky button only in the food menu pages.
      Again with a @bernhard tip I moved into the customization of this simple module and the related hook.
      ---
      How to use this module
      After installed, it creates the page /admin/page/allergens/ and the module is to be setted up. The first field is a CKEditor with multi-language. This is the place where to write the informations that will be shown into the page. The next field is a simply text-area where to place a bit of JS that will be appended to the markup of the text (omit the 'script' tags). I also putted a checkbox with a silly statement: this to think at least twice on the safety of the written JS. Now comes the first way to display the link to the page
      Field Note with Link. Enable and save it. The module will display a new row with 4 selects (1 standard and 3 ASM):
      View mode (to show the page as Panel or as Modal PopUp); Templates to select: select one or more and save before proceed, so the  asm-select of the pages will be populated showing all the pages of the selected templates. Pages to select: also here select at least one and save before proceed to populate the asm-select for fields only with the ones that belong to the selected pages. Select the fields where to place the note and save again. That's all: now you will find into the notes of the selected fields the link "See the List of Allergens".
      At the same way, the option for the sticky button, but with a plus
      The field select is obviously unnecessary, but you could play with the last row: the inline styles to fix your sticky button where you like. Here you could set the sticky position of the <div> and the absolute ones of the <a>.

      Video Explanation
      In these screencasts you could see a custom JS that show a "copy" button near a "hanna-code" call.
      This because I've set a specific one for each allergen to show up a tooltip in the front end.

      Registrazione #33.mp4  

      Registrazione #34.mp4 ---
      Last but not the least
      Actually it works fine for my needs, even if it's much improvable: I'm working on the permissions creation, the uninstall section, a separate configs and defaults and how to include the hook into the module leaving free the ready.php. According to a simpler uninstall. Also I would make the link text as a dynamic text field, so it will be more flexible.
      I always learn a lot here, so I would share my code for whom it could be interested.
      I removed the hanna code references, but I provide you the html list of the allergens, English and Italian too, so you can paste them into the "source" of the CKEditor field to have a ready to use module.
      Obviously you are free to modify the code as per your needs.
      Please, keep in mind that I'm not a pro coder and I beg your pardon for my verbosity (speaking and coding). 😉
      I hope be helpful or for inspiration.
      Bye
      ready.phpList-ITA.htmlList-ENG.htmlAllergens.module
      README.md
    • By Robin S
      This module is sort of an upgrade to my earlier ImageToMarkdown module, and might be useful to anyone working with Markdown in ProcessWire.
      Copy Markdown
      Adds icons to images and files that allow you to copy a Markdown string to the clipboard. When you click the icon a message at the top left of the screen notifies you that the copying has occurred.
      Screencast

      Note: in the screencast an EasyMDE inputfield is used to preview the Markdown. It's not required to use EasyMDE - an ordinary textarea field could be used.
      Usage: Images
      When you hover on an item in an Images field an asterisk icon appears on the thumbnail. Click the icon to copy an image Markdown string to clipboard. If the "Description" field is populated it is used as the alt text.
      You can also open the "Variations" modal for an image and click the asterisk icon to copy an image Markdown string for an individual variation.
      Usage: Files
      When you hover on an item in a Files field an asterisk icon appears next to the filename. Click the icon to copy a link Markdown string to the clipboard. If the "Description" field is populated it is used as the link text, otherwise the filename is used.
       
      https://github.com/Toutouwai/CopyMarkdown
      https://processwire.com/modules/copy-markdown/
    • By BitPoet
      I've realized that I've been jumping back and forth between the PW API docs and the source code for site modules far too much. The idea to hold all necessary documentation locally in one place has occurred to me before, but getting PHPDocumentor et al set up and running reliably (and producing readable output) as always been too much of a hassle. Today I was asked how I find the right hooks and their arguments, and that inspired me to finally get my backside down on the chair and whip something up, namely the
      Module Api Doc Viewer
      ProcessModuleApiDoc
      It lets you browse the inline documentation and public (optionally also protected) class/method/property information for all modules, core classes and template files in the ProcessWire instance. The documentation is generated on the fly, so you don't have to remember to update your docs whenever you update a module.
      The module is quite fresh, so expect some bugs there. Behind the scenes it uses PHP-Parser together with a custom class that extracts the information I needed, and the core TextformatterMarkdownExtra module for rendering the description part in the phpdoc style comments.
      This is not a replacement / competitor to the API Viewer included in the commercial ProDevTools package. There is quite some information included in the inline documentation that my module can't (and won't) parse, but which makes up parts of the official ProcessWire API docs.
      This, instead, is a kind of Swiss army knife to view PHPDoc style information and get a quick class or function reference.
      If you feel daring and want to give it a spin, or if you just want to read a bit more, visit the module's GitHub repository.
      This is the overview page under "Setup" -> "Module API Docs":

      And this is what the documentation for an individual class looks like:

      The core module documentation can of course be found online, but it didn't make sense not to include them.
      Let me know what you think!

    • By tcnet
      File Manager for ProcessWire is a module to manager files and folders from the CMS backend. It supports creating, deleting, renaming, packing, unpacking, uploading, downloading and editing of files and folders. The integrated code editor ACE supports highlighting of all common programming languages.
      https://github.com/techcnet/ProcessFileManager

      Warning
      This module is probably the most powerful module. You might destroy your processwire installation if you don't exactly know what you doing. Be careful and use it at your own risk!
      ACE code editor
      This module uses ACE code editor available from: https://github.com/ajaxorg/ace

      Dragscroll
      This module uses the JavaScript dragscroll available from: http://github.com/asvd/dragscroll. Dragscroll adds the ability to drag the table horizontally with the mouse pointer.
      PHP File Manager
      This module uses a modified version of PHP File Manager available from: https://github.com/alexantr/filemanager
       
×
×
  • Create New...