-
Posts
1,360 -
Joined
-
Last visited
-
Days Won
49
Everything posted by flydev
-
Thanks for this moment @dragan
-
Now, the "package manager"; From this window, you can create or delete a package, and also download a packages from the "server backups folder" to your computer. But the best feature is that you can "sync" packages stored on a third-party provider. This mean that the module will check for existing packages on GoogleDrive, Dropbox or whatever (it depend on how you configured Duplicator) and list them so you can delete or download them to your computer, and deploy your nice website in a minute! In the following example, I have packages on my Local Server, on GoogleDrive and Dropbox :
-
Today, there is a small a preview of a successful deployment (on localhost) using Duplicator : Create a package in the backend Download the package and the installer Upload it to the new hosting Navigate and run the installer
-
Hello guys ! The Gitlab server is fixed and running, you can update the module to the latest version. All SDKs can be downloaded separately without using composer, the link of each SDK is provided in the module settings. You must uninstall the previous version before testing it. Thanks!
-
I am checking for this, and it appear that all the SDKs are compiled despite using /*NoCompile*/ on the require_once. Also I note that this feature was introduced in PW 3.0.43, so I assume the file will be compiled for PW 2.7. Concretely, what is the bad thing about leaving all those SDKs file being "FileCompiled" ? if($this->useFTP) { require_once(__DIR__ . '/Classes/FTPClient.php'); } if($this->useAmazonS3) { require_once (/*NoCompile*/ __DIR__ . '/SDKs/aws/aws-autoloader.php'); require_once(__DIR__ . '/Classes/ClientAmazonS3.php'); } if($this->useDropbox) { require_once (/*NoCompile*/ __DIR__ . '/SDKs/dropbox/autoload.php'); require_once(__DIR__ . '/Classes/ClientDropbox.php'); } if($this->useGoogleDrive) { //require_once __DIR__ . '/SDKs/google/autoload.php'; // oh my.. require_once (/*NoCompile*/ __DIR__ . '/Classes/GoogleAutoload.pain.php'); googleAutoload(); require_once(__DIR__ . '/Classes/ClientGoogleDrive.php'); } Anyway, for the people who have the module in hand, I bumped the module to the version 0.0.36. The Gitlab server is not running up but will give a download link in PM as I would appreciate a test on a Windows machine..
-
Under Edit field > Input > CKEditor Settings > CKEditor toolbar, you need to add the button: A11ychecker Save, then you should see the new button
-
Checking expiration_date in the selector should do the trick. $todaysdate = date("F j, Y H:i"); $today = strtotime($todaysdate); $ads = $pages->find("parent.template=client, expiration_date<$today, sort=expiration_date"); echo count($ads);
-
You are not incrementing $alert_count. It should be : $alert_count += 1; // not =+ 1;
-
Inclusion (require/include) of libraries/files in a hook
flydev replied to a-ok's topic in API & Templates
I understand now what you mean by no error. There is one last error, which can be seen if you dump the variable $response. You could see that SendGrid return an error code which can be something like that : statusCode => 401 body => "{"errors":[{"message":"Permission denied, wrong credentials","field":null,"help":null}]}" The reason is that the global $sgAPIKey in the function is not getting the value from the $sgAPIKey defined with the key (from some reason that someone might explain here..) To solve the issue, just set your API key in the function directly. [...] function send_email($from_email, $to_email, $subject, $body) { $sgAPIKey = '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'; // Lucy [...] -
And I was sure YOU will ask that ! Sure, I am already trying to get back my Gitlab server. The server was hosted in a VMware guest machine, and when plugged the hdd and put the virtual machine ON, the network simply does not work anymore. Can't ping anything, but I know how to fix it, i am just too lazy those days. Edit: Just to say, I still have the code and used the module in the last days, but it look like its not the Windows compatible version..
-
Inclusion (require/include) of libraries/files in a hook
flydev replied to a-ok's topic in API & Templates
Sorry but I do not understand, could you explain a bit more please ? Where do you first defined the send_mail () function ? (its not a ProcessWire or SendGrid function). If I assume you defined the function in, for example, _func.php, its normal you got an error of an undefined function. Just assuming... In your last code snippet, everything look fine (I would have defined the function outside the hook). -
Inclusion (require/include) of libraries/files in a hook
flydev replied to a-ok's topic in API & Templates
@oma Call SendGrid like that : new \SendGrid(); (As Adrian said, its a namespace issue) @teppo I used WireFileTools just for the example, the bénéfit of this class is that it provide the ProcessWire API to the object. Sorry for the short answer, i am on mobile. -
Inclusion (require/include) of libraries/files in a hook
flydev replied to a-ok's topic in API & Templates
Yes you can. $this->addHookAfter('Pages::save', function(HookEvent $event) { $arguments = $event->arguments(); $page = $event->arguments(0); if($page->template == 'user') { // Require relevent libraries $wft = new WireFileTools(); $wft->include('sendgrid-php/sendgrid-php.php'); $from = new \SendGrid\Email("Example User", "test@example.com"); $subject = "Sending with SendGrid is Fun"; $to = new \SendGrid\Email("Example User", "test@example.com"); $content = new \SendGrid\Content("text/plain", "and easy to do anywhere, even with PHP"); $mail = new \SendGrid\Mail($from, $subject, $to, $content); $apiKey = getenv('SENDGRID_API_KEY'); $sg = new \SendGrid($apiKey); $response = $sg->client->mail()->send()->post($mail); // dump SendGrid object with TracyDebugger bd($mail); } }); -
Hello @Niku, sorry I am not giving you the right answer but.. You could take a look at this module : https://modules.processwire.com/modules/inputfield-select-multiple-transfer/ From the module's description it look like it could save you time
-
Best approach for maintaining millions of short news
flydev replied to vadimmil's topic in General Support
There are some good reads in the forum too : -
The module got renamed and updated a bit as its not intended to run only on the backend, but work also on frontend side. - Now, the administrator can choose to activate or not the backend login buttons. - The providers are added "dynamically". You have to simply edit a JSON config file which once saved, will show the required fields in the module settings. For example the following JSON config will only provide Google as login provider : { "providers": { "google": { "className": "Google", "packageName": "league/oauth2-google", "helpUrl": "https://console.developers.google.com/apis/credentials" } } } Small note for pw users : If like me you did not know, there is another module that manages OAuth2 authentication. Feel free to use the one which suit your needs! more info there: @jmartsch you should create a new module thread
-
With this markup and field options : $markup = array( 'list' => "{out}\n", 'item' => "\n\t<div class='form-group input-group'>\n{out}\n\t</div>", 'item_label' => "{out}", 'item_icon' => "<span><i class='fa fa-fw fa-{name}' aria-hidden='true'></i></span>", 'item_content' => "{out}", 'item_error' => "\n<p class='field--error--message'>{out}</p>", 'item_description' => "\n<p class='field__description'>{out}</p>", 'item_toggle' => '' //.... etc ); // field setup $field->icon = 'envelope'; $field->label = ' '; I get the following result : <div class="form-group input-group"> <span> <i class="fa fa-fw fa-envelope" aria-hidden="true"></i> </span> <input id="name" class="InputfieldMaxWidth" name="name" maxlength="2048" type="text"> </div> Another idea could be to set the markup option of the label to something like {{replaceme}} {out} {{/replaceme}} and change those tags when you render the form with a str_replace or a custom function, you see ?
-
Edit September 2022 See this thread: --- I would have taken another way. As each photo are Page, he could create a module which work with a custom MySQL table where he update the like of a page with some informations aside, like the userID (the user who like the page), the pageID (the page being liked) , a likeStatus (like or unliked) and a timestamp. I made a small module to show the idea : then in the frontend, you can render a 'like' button on choosen templates, and finaly get the total number of likes of a page and the most liked page, see: <?php namespace ProcessWire; $likesmod = $modules->get('LikeSystem'); // render a 'like' button $content = $likesmod->render(); // total like of the page $content .= "Number of likes for this page: " . $likesmod->getTotal($page->id); // most liked page $limit = 1 $mostliked = $likesmod->getMostLikedPage($limit); $content .= "<br>Most liked page: " . $pages->get($mostliked[0]['pageId'])->title . "(" . $mostliked[0]['pageId'] . ") " . " (N likes: ". $mostliked[0]['likesCount'] . ")";
-
hi @MilenKo you should read this post made by Ryan, and adapt it, it contain nearly all answers. Anyway your code should work if the comments/template are correct.
-
Method(s) to cycle through foreach/compare values of Children
flydev replied to creativejay's topic in API & Templates
Ok got it, you need to allow the anonymous function to "capture" local variables. Try the following ( note the use($f) ) : $byField = array_reduce($children->getArray(), function($carry, $child) use($f) { if(!is_object($child->$f) && !is_null($child->$f)) // avoid illegal offset type warning $carry[$child->$f][] = $child; // NO MORE ISSUE return $carry; echo count( $carry ); }, array()); -
Method(s) to cycle through foreach/compare values of Children
flydev replied to creativejay's topic in API & Templates
What is going on if you call it that way (minus $) ? : $carry[$child->f][] = $child; // no more ISSUE -
Admin not working after moving site to new server (Error 403)
flydev replied to stipps's topic in General Support
You can find more information there: https://processwire.com/docs/security/file-permissions/ -
Admin not working after moving site to new server (Error 403)
flydev replied to stipps's topic in General Support
You could try to copy the root dir containing the site and do a chmod -R 777 on it (just for testing purpose!) - result ? -
How to attach google recaptcha in default pw admin login form ?
flydev replied to adrianmak's topic in General Support
Hi @adrianmak You can achieve this by using hooks and my ReCaptcha module. First install the MarkupGoogleReCaptcha module then in file ready.php, write the following code : /* * replace the LAST occurence of $search by $replace in $subject */ function str_lreplace($search, $replace, $subject) { return preg_replace('~(.*)' . preg_quote($search, '~') . '~', '$1' . $replace, $subject, 1); } /* * replace the FIRST occurence of $search by $replace in $subject */ function str_freplace($search, $replace, $subject) { $from = '/'.preg_quote($search, '/').'/'; return preg_replace($from, $replace, $subject, 1); } $captchamod = wire('modules')->get("MarkupGoogleRecaptcha"); wire()->addHookProperty('Page::captcha', function($event) use ($captchamod) { $event->return = $captchamod; }); wire()->addHookAfter('Page::render', function($event) { $template = $event->object->template; $page = $event->object; if ($template == 'admin' && !wire('user')->isLoggedin()) { $captchaScript = $page->captcha->getScript() . '</body>'; $captchaHtml = $page->captcha->render() . '</form>'; $event->return = str_freplace('</form>', $captchaHtml, $event->return); $event->return = str_lreplace('</body>', $captchaScript, $event->return); } }); wire()->addHookAfter('Session::authenticate', function($event) { $page = wire('page'); $template = $page->template; if ($template == 'admin') { if ($page->captcha->verifyResponse() == false) { wire('session')->logout(); wire('session')->redirect(wire('config')->urls->admin); } } });