-
Posts
1,360 -
Joined
-
Last visited
-
Days Won
49
Everything posted by flydev
-
Good, now I think that your google challenge is not successful. Be sure that you saved the changes in your list of supported domains once you added the localhost. Anything in the developer console ?
-
Yes it is. Read my last edit in my previous post. Localhost for testing is fine, no problem with that.
-
Sorry, I totally missed it ! Will try to find the time asap
-
Hi @LAPS try the following : In ready.php put the following code : $captchaobj = null; wire()->addHookProperty('LoginRegister::captcha', function ($event) { $event->return = wire('modules')->get("MarkupGoogleRecaptcha"); }); wire()->addHookAfter('LoginRegister::buildLoginForm', function ($event) { /* @var $form InputfieldForm */ $obj = $event->object; $form = $event->return; $form->description = false; // remove the description $f = new InputfieldMarkup(); $f->markupText = $obj->captcha->render(); foreach ($form->children as $field) { if ($field instanceof InputfieldSubmit) { // find the submit button $form->insertBefore($f, $field); // insert reCAPTCHA before the submit button } } $event->return = $form; }); wire()->addHookBefore('LoginRegister::processLoginForm', function ($event) use (&$captchaobj) { $obj = $event->object; $captchaobj = $obj->captcha; }); wire()->addHookBefore('Session::login', function ($event) use (&$captchaobj) { if (!is_null($captchaobj) && $captchaobj->verifyResponse() == false) { $event->arguments(0, ''); $event->arguments(1, ''); $event->arguments(2, false); $event->return = false; } }); Just one thing, I couldn't get the invisible mode to work with LoginRegister, only the reCAPTCHA v2. edit: a small hint about the getScript() : you should call it from the main file, I mean, your "index.php" and only if the user isn't loggedin. if(!$user->isLoggedin()) { echo $modules->get("MarkupGoogleRecaptcha")->getScript(); }
-
Hi @sebr You have to install the Process module called ProcessDuplicator. You can find it in the menu Modules > Install > ProcessDuplicator then once installed, you will find the module under Setup > Duplicator or click the link <eye-icon> Package Manager in Duplicator.
-
You will end up with a PHP function (written by @mindplay.dk) ,two templates and pages which will define your menu. I will write the tutorial a bit later in the afternoon.
-
How do I make ProcessWire display the 404 "page not found" page?
flydev replied to ryan's topic in API & Templates
Thanks you. it turns out that with TemplateEngineFactory it works - at least for me - in templates, the 404 is fired, but not in bootstrapped script ? It is your case ? And I ended up testing to throw a 404 from a bootstrapped script on two others websites which don't have TemplateEngineFactory and also on a fresh install and it doesn't work, I think we can dismiss the module. -
if you have a little courage (and if anyone else is interested), I can write you a little tutorial but you must put your hands dirty ?, let me know.
-
Hi @Robin S In a process module I am writing, there is a function to create a new user. With PasswordGenerator installed (a must have!) I get the following notice : PHP Notice: Trying to get property of non-object in .../modules/PasswordGenerator/PasswordGenerator.module:76 When I dump $field, Tracy return a null value : $field = $inputfield->hasField; // line 47 There is nothing special in the function, I just declare a new InputfieldPassword : [...] // password $field = new InputfieldPassword(); $field->attr("id+name","password"); $field->label = __("Mot de passe"); $field->required = true; $field->minlength = 6; $field->columnWidth = 50; $form->append($field); [...] $out = $form->render(); return $out; Thanks.
-
How do I make ProcessWire display the 404 "page not found" page?
flydev replied to ryan's topic in API & Templates
I can't get the 404 working in a template or bootstrapped script : <?php namespace ProcessWire; include_once(__DIR__ . '/../index.php'); if(!$config->ajax || !$user->isGuest()) { throw new Wire404Exception(); } as @Pete already said, it amusingly throws an exception on my install. I am on PW 3.0.88 but was not working on 3.086 either. What I can check ? If it help, I have TemplateEngineFactory installed and I think its the main cause. I might have posted on the module's thread... -
this should work : $field = $fields->get('comments'); $comments = $field->type->find($field, "sort=-created");
-
Display a different, login-related menu item to logged in users
flydev replied to LAPS's topic in General Support
<?php namespace ProcessWire; if($user->isLoggedin()) { // you can go more deeper with roles, etc... render_my_sekret_menu(); }- 1 reply
-
- 4
-
I needed something similar today, still working on it. To get you started (it require more check in the hook), in ready.php : <?php wire()->addHookBefore('LoginRegister::createdUser', function($event) { $u = $event->arguments[0]; $u->roles->add(wire('roles')->get("custom-role")); $u->save(); }); Edit: used LoginRegister::createdUser instead because the role was added but not took into account.
-
There is the solution with the hook. In ready.php put the following code : wire()->addHookBefore('InputfieldFile::fileAdded', function($event) { $inputfield = $event->object; // handle to the image field if(!$inputfield instanceof InputfieldImage) { // we need an images field, not a file field return; // early return } if(version_compare(wire('config')->version, '2.8.0', '<')) { // horst code $p = $inputfield->value['page']; // get the page, PW < 2.8 } else { $p = $inputfield->attributes['value']->page; // get the page, PW >= 2.8 | 3.0 (or only from 3.0.17+ ??) } if($p->id == 1029) { // adjust page id which contain the gallery image field $image_id = 0; foreach($p->gallery as $image) { if(!empty($image->image_id)) $image_id = $image->image_id; $newimage = $image; } if(isset($image_id)) $image_id++; // increment id else $image_id = 0; $p->get('gallery')->trackChange('image_id'); // prepare page to keep track for changes $newimage->set('image_id', $image_id); // set the id $p->save('gallery'); // save the field } }); result :
-
Still no time sorry
-
hi @Krlos the file is stored in a folder called Duplicator on the drive account, then the file is shared with the email address you configure in Duplicator > GoogleDrive settings.
-
Two ideas, the first one, you can make a unique name for each image and identify them by their name. But eh.. if you can't control the image's name (eg: because there are some others editors) then you must go for the second. The second, use a custom field - ID - on your image field and in your loop (the one which iterate all image to make the gallery), write the ID field value as data attribute to the images. <?php foreach($images as $image) { echo "<img src='$image->url()' data-id='$image->ID'>"; } To automate the update of the custom ID field when images are added to the image field, you will have to hook and do your logic inside the hook: checking for existing ID and assigning a new one.
-
[SOLVED] Weird problem with copy of production site
flydev replied to Krlos's topic in General Support
try Duplicator -
To get you started, I give you an example of an ajax request triggered by a noUiSlider's event which update the markup. Do not hesitate to ask if you don't understand something. Javascript code : // slider element var slider = document.getElementById('noUiSlider'); // create the slider object noUiSlider.create(slider, { start: [0, 100], step: 1, // avoid float values range: { 'min': 0, 'max': 100 } }); // change the value when noUiSlider values are updated slider.noUiSlider.on('update', function( values, handle ) { if ( handle ) { $("#noUiSlider-data").data("max", values[handle]); } else { $("#noUiSlider-data").data("min", values[handle]); } }); // on event 'set' send ajax request slider.noUiSlider.on('set', function( values, handle ) { // get the min and max from the data attribute of #noUiSlider-data $data = {min: $("#noUiSlider-data").data("min"), max: $("#noUiSlider-data").data("max")}; // ajax request $.ajax({ url: $(this).data('url'), // url from the data attribute of #noUiSlider type: "post", data: $data }).done(function (response, textStatus, jqXHR) { $('#list').html(response); // write markup to #list element }) }); PHP code : <?php namespace ProcessWire; $list = ''; $limit = 100; if(isset($input->post->min) && isset($input->post->max)) { $min = $input->post->min; // don't forget to sanitize $max = $input->post->max; // don't forget to sanitize $li = ''; $products = $pages->find("template=product, start=$min, limit=$max"); // let assume there is a template 'product' foreach ($products as $product) { $li .= "<li>". $product->title . "</li>"; } $list = "<ol>$li</ol>"; echo $list; } ?> HTML Markup : <div id="noUiSlider" data-url="<?= $page->url; ?>"></div> <span id="noUiSlider-data"></span> <div id="list"> <?= $list ?> </div> #noUiSlider is the slider element #noUiSlider-data will contain values changed from the #uiSlider element #list is the element updated by the ajax response enjoy
- 2 replies
-
- 11
-
- nouislider
- range-slider
-
(and 1 more)
Tagged with:
-
A small idea is to add a checkbox field - "created_by_module" - to the template and check the box when the page is created by the module. Then in the hook you can check if this field is checked or not. please have a look to this post :
-
Hi, check this post (the first answer about the family tab) :
-
@joe72joe Are you sure that this loop won't insert another double quotes inside the double quote of the data attribute ? <div data-groups="<?php foreach($page->portfoliothumbs as $port) { echo "{$port->lb_home_port_datagroup}"; } ?>" Will be more easy if there is something live to check ya.
-
In addition to what @Macrura said, @pwuser1 check those videos :