Jump to content

webhoes

Members
  • Content Count

    210
  • Joined

  • Last visited

Everything posted by webhoes

  1. Hello, For a Dutch site with padloper a visitor can enter their email. Due to a lot of mis-typing they now also need to confirm their email. How do I change the word "Confirm" to something like "Bevestig email"?
  2. @Jan Romero, I got it working with your code. Thanks.
  3. @Jan Romero, thanks. I found the same issue. I renamed that div as I already use content for template strategy. I made this <div id="live-search"></div> Yes, I changed the % to ~, not sure it that is correct either. If using % it will also give me a lot of unrelated results as it searches in both title and body. Currently I trying to fix that the div with results does not grow downwards but upwards making that you can't see the results.
  4. @Jan Romero, I tried your code on a website. I do see the url change on typing in the searchbox, tracy also shows the search term. If I press enter I get to the search page with the correct results. I just miss the live search part. My setup is a _main.php with the search form and the javascript code. A search template with url /search/ with the code for the actual search. If have set it up on this test site. meibergen.webhoes.nl Do you have any clue why I don't have the live search?
  5. @flydev, thanks works perfectly!
  6. Hello, I want to add an item to the user navigation menu. In the picture below I added it (My studbooks) in the core files. It is hookable, but I can't get the hook to work. Ready.php // /* to figure out */ $this->addHookAfter('AdminThemeFramework::getUserNavArray', function(HookEvent $event) { // Get the object the event occurred on, if needed $AdminThemeFramework = $event->object; $AdminThemeFramework = $navArray(); // An 'after' hook can retrieve and/or modify the return value $return = $event->return; /* Your code here, perhaps modifying the return value */ $navArray[] = array( 'url' => '/my-studbooks/', 'title' => $this->_('My studbooks'), 'target' => '_top', 'icon' => 'eye', ); // Populate back return value, if you have modified it $event->return = $return; }); What should I change to get it working from ready.php
  7. @MarkE, Thanks! This is a total different I was looking at and mine doesn't work. I will play with this and see if I can get it to work in my setup.
  8. Interesting. Are you willing to share you module? I have not been able to get a secure setup myself. The pageload in my case is my security setup. I check for referenced users from a parent page or parent parent page. This is really time consuming.
  9. I made a similar something, but it increased the pageload by 3 seconds. This is too much. Do you give the user temporarily page-edits upon granted request of that page?
  10. @MarkE, did you get this working without giving user page-edit rights?
  11. Hello, I am working on a site where multiple users have one ore more pages (studbook). These pages can contain children (animal) and animal can have a child (transfer). I created an admin before the PW admin. Here users can see their the pages the have their users_created_id. I use the feel module for editing. But if someone right clicks the edit button, they end up in the PW admin and can see everything (not allowed). So I created a module to redirect everybody but superuser from the admin templates (except if page id == 10, the edit template). This sort of makes is secure, but if a user knows the id of the page they can still type /processwire/page/edit/?id=xxxx and see that page. I have been working some days around this, but no solid solution came up. I do have the formbuilder module available if this can help. I also thought of making a role for every studbook. That would mean 35 roles and 35 studbook templates. Also animal and transfer templates need to be duplicated per studbook otherwise a user will still be able to see others. What other options are there to make it so people can only see their studbook and their child pages? Nice to have would be that to or more selected users can see and or edit that studbook. Preferbly all without page-edit rights so I can block everyone from the PW admin.
  12. @renobird, have you re-considered releasing the code for your ticket system or partly. Basicly the part that creates new tickets from emails and sends updates is the most important and difficult.
  13. Thanks @jmartsch and @bernhard I have updated the module with your improvements. Works very smooth...
  14. Damnnn... Or you name your module properly instead of having .php as extension. I could not find it among the modules, but I was confused with some other hooks that are not modules (like in ready.php) that just do their thing. Luckily, it works now.
  15. Could not get something working with those changes. After some more searches I came up with this, close to the examples but also still not working. public function init() { // add a hook after the $pages->save, to issue a notice every time a page is saved $this->pages->addHookBefore('save', $this, 'updateProduct'); } /** * Example1 hooks into the pages->save method and displays a notice every time a page is saved * * @param HookEvent $event * */ public function updateProduct($event) { /** @var Page $page */ $page = $event->object; //$page = $event->arguments('page'); if($page->template != 'product') return; $fields = $page->fields; $price = $fields->get('pad_price'); $rrp = $fields->get('pad_rrp'); $discount = $rrp - $price; $percentage = $discount/$rrp * 100; $page->of(false); $page->set('pad_discount', $percentage); $this->message('test'); }
  16. Hello, I have made a module, but I can't get it to work. I have 2 fields with price (price and rrp). On save I want to calculate the difference in percentage and save it to the discount field. It does not update the field. What am I doing wrong? class UpdateDiscount extends WireData implements Module { public static function getModuleInfo() { return array( 'title' => 'Custom discount updater', 'version' => 1, 'summary' => 'Auto update percentage based on prices.', 'singular' => true, 'autoload' => true, 'icon' => 'money', ); } public function init() { // add a hook after the $pages->save, to issue a notice every time a page is saved $this->pages->addHookAfter('save', $this, 'updateProduct'); } /** * Example1 hooks into the pages->save method and displays a notice every time a page is saved * * @param HookEvent $event * */ public function updateProduct($event) { /** @var Page $page*/ $page = $event->arguments[0]; if($page->template != 'product') return; $price = $page->pad_price; $rrp = $page->pad_rrp; $discount = $rrp - $price; $percentage = $discount/$rrp * 100; $page->setAndSave('pad_discount', $percentage); } }
  17. I tried this for a site, but the new button is still visible. The template studbook can have a child with template animal. I have resticted a per page right edit rights for the studbook. On that page you can use the tab to add a new animal. But all people can see the tree and now with every studbook there is a option for new. If this is not visible, only people with the right page rights you can add a child from the page... I am using the current dev version of pw. $this->addHookAfter('ProcessPageListActions::getActions', null, function(HookEvent $event) { $p = $event->arguments[0]; $actions = $event->return; if($p->template->name == 'studbook') { unset($actions['new']); } $event->return = $actions; });
  18. I did test this some time ago. To make this work I would have to make a user specific branch upon registering and dynamicaly give that user rights to that particular branch. that branch would contain all data for that user different child pages. I think that would be difficult to achieve and maintain.
  19. Interesting stuff... But what is defined as one branch? Is that one of the first childs of Home? If so, how would you deal with multiple branches that should all be treated equally? User may only see and edit childs of those branches he created himself? And to make it a little more complicated, some of those pages also contain child pages to which only the creating user should have access.
  20. For this site seeing pages of others in the tree is not an option. Specially with the new GPDR law.
  21. @bernhard if there is another safe way to give user edit rights and still make sure they can't see or edite pages of others I don't mind changing letting them in the backend and create processmodule pages. Current pseudo backend looks like this. Everything a user adds is private and may not be seen by another or changed by another. The only exception is the classifieds section which is to be seen in the frontend (but also in the backend only for the user who made it). I see in your article that you also use forms. But then I would need to apply the same logic as I do now (or lacking to have done now). What would I need to do If don't want anyone to see the standard pw backend (including the tree). And only have them see somthing like image above, but if they click on 'edit' they can use the pw backend for adding/changing text and images (with use of all the backend security present) of that particular page. Or use the page tree and make sure everything they did not make is hidden (except for the parent templates). Turtles is parent for turtle. They did not create the Turtles page but it groups all turtles from all users. That would be something like this Turtles turtle 2 Grourps group 1 Classifieds classified 4 classified 7 Another user would see different pages. I did tried something like this before, but could not get this running correctly. ohjah, the site is multilangual and with the api the title and name are synchronized on save. Also the name is based on userid and a timestamp so no user can have the same name. Title can be the same as this does not creates issues. I know a lot of questions, but I am quite proud of how far I cam so far, but are still far from being a programmer and understanding how it all works.
  22. @bernhard I use the frontend because all the user don't have acces rights to the backend. I have created a pseudobackend where they can add or change their own specific pages. This is the way to keep them from seeing the pw backend and each others pages and being able to edit each others pages (has got sensitive material). from the pw backend I have set the limits, but with api upload these are bypassed. If possible I would like to use the same modules as the backend, but then in a pseudobackend page/form. Could not get this working. Now it is all forms and api's.
  23. I use uikit v3 upload component to upload images. This works, but if the image is too big, that page crashed completely. I would like to either resize all images to max width 900 px on upload or use the same upload upload code as the pw backend does. I currently use this code. <div class="js-upload" uk-form-custom> <input type="file" multiple> <button class="uk-button uk-button-default" type="button" tabindex="-1" onsubmit="validate()">Upload</button> </div> <progress id="js-progressbar" class="uk-progress" value="0" max="100"></progress> <?php $uploadPath = '/upload.php?pid=' . $page->id; $uploadPath = $sanitizer->url($uploadPath); ?> <script> var bar = document.getElementById('js-progressbar'); UIkit.upload('.js-upload', { url: '<?php echo $uploadPath;?>', multiple: true, beforeSend: function () { console.log('beforeSend', arguments); }, beforeAll: function () { console.log('beforeAll', arguments); }, load: function () { console.log('load', arguments); }, error: function () { console.log('error', arguments); }, complete: function () { console.log('complete', arguments); }, loadStart: function (e) { console.log('loadStart', arguments); bar.removeAttribute('hidden'); bar.max = e.total; bar.value = e.loaded; }, progress: function (e) { console.log('progress', arguments); bar.max = e.total; bar.value = e.loaded; }, loadEnd: function (e) { console.log('loadEnd', arguments); bar.max = e.total; bar.value = e.loaded; }, completeAll: function () { console.log('completeAll', arguments); setTimeout(function () { bar.setAttribute('hidden', 'hidden'); }, 1000); alert('Upload Completed'); location.reload(); } }); </script> and this is upload.php <?php namespace ProcessWire; include './index.php'; $p = $pages->get($input->get->pid); //$p = $pages->get($_GET["pid"]); $p = wire('pages')->get($_GET["pid"]); //echo barDumpLive($p); if(isset($_FILES['files'])) { $file_tmp = $_FILES['files']['tmp_name'][0]; $file_ext = pathinfo($_FILES['files']['name'][0], PATHINFO_EXTENSION); $extensions = array("jpeg","jpg","png", "gif"); if(in_array($file_ext, $extensions) === true) { /* $original = $file_tmp.$file_ext; $options = array('upscaling' => false, 'quality' => 100); $imageSizer = new ImageSizer($p->images->path().$original, $options); $success = $imageSizer->resize(500, 500); if ($success) */ //$file_tmp.$file_ext->width(800); //change width to 800 to avoid images that are too large $p->images->add($file_tmp); } $p->save('images'); } I have tried several option in resizing but the moment I change the code it stops working. Where should I implement a solution? Or the other option is to use the inputfieldImage on the fontend. I could not get that to actually upload an image.
  24. Everybody thanks for your input. I just bought a refurbished macbook pro 15" 2015 with 256Gb with 2 months of apple warranty left and 12 months warranty of the retailer. I got a new display and new accu (complete top casing) with 0 cycles. This should sufficient for the coming years. Will get it tomorrow with the postalservice. Looking forward to unpack it 😄
  25. thanks for the reply @ryan. Very clear, but also creating doubts 😉 I am afraid the prices for macbooks are higher here in the netherlands. Eur 975 for a sealed 2017 13 is very cheap. I do like your point of getting the oldest model with the most warranty. The cheapest I could find is a 2015 model 15" with a 512Gb SSD for eur 1900. That one is new and comes with full warranty. I have a company so I can deduct the VAT. All other are between 1 and 3 years old (first sold) and so most of them are without warranty. There is only some warranty on the retina display. But that is also only for a period of 4 years. That makes it tricky to buy a 3 year old model. It is a decision between starting cheap (13", 8Gb and 128Gb) with full warranty for eur 975 or invest eur 1900 and have good specs(2015, I7, 512Gb) with full warranty. I can use an external display when I am home.
×
×
  • Create New...