Jump to content

flydev

Members
  • Posts

    1,327
  • Joined

  • Last visited

  • Days Won

    47

Everything posted by flydev

  1. 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.
  2. 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...
  3. this should work : $field = $fields->get('comments'); $comments = $field->type->find($field, "sort=-created");
  4. <?php namespace ProcessWire; if($user->isLoggedin()) { // you can go more deeper with roles, etc... render_my_sekret_menu(); }
  5. 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.
  6. 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 :
  7. 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.
  8. 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.
  9. 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
  10. I didn't understood everything but you can take a look at this thread : and this module if it help :
  11. 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 :
  12. Hi, check this post (the first answer about the family tab) :
  13. @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.
  14. Hi @iNoize, feel free to PM me tonight some details (timeline, schedule etc. if exist).
  15. In addition to what @Macrura said, @pwuser1 check those videos :
  16. Hi @Federico try : $editpage = $this->pages->get($pageID); // get the collection of inputs that inside the selected page $inputfields = $editpage->getInputfields(); foreach($inputfields as $inputfield) { $value = $inputfield->value; // do something }
  17. You have three possibilities. The first one, you can write the code in a template file inside your site/template folder, the second you can write the code in a bootstrapped script in the root directory (or where you want, you just have to adjust the path of the index.php). The thrid, inside a module. Read the whole thread, you should find what you need. What are you trying to achieve ?
  18. Yes, thanks. @rafaoski added a site profile using Bootstrap 4 updated there :
  19. Hello, replace in your module $page by $this->page and everything should be fine. $form->attr("id+name",'$page->name'); // should be $this->page->name $field = $field->getInputfield($page); // should be this->page
  20. PwCron is not required anymore, you can set your job calling directly site/modules/Duplicator/cron.php https://github.com/flydev-fr/Duplicator#system-cron
  21. I will look at it tonight, its strange as I can't reproduce it. I set the same package name, same settings then the package is uploaded but nothing deleted ? Could you tell me if the bucket already contain other files ? Edit: my logs :
  22. Good and did you tested to upload a file with a regular FTP client ? look like a permission issue. Check your PM. Edit : @Peter Knight please enable the "Passive Mode" setting in Duplicator > FTP settings
  23. @jeve please change the "Remove backup packages older than" setting to "Never" and try again then let me know @Peter Knight are you sure you are not mixing SFTP and FTPS ? SFTP is based on ssh protocol which is not supported.
×
×
  • Create New...