Jump to content

gebeer

Members
  • Posts

    1,225
  • Joined

  • Last visited

  • Days Won

    37

Everything posted by gebeer

  1. Why do you have this requirement? JS plugins like https://infinite-scroll.com/ are there for a reason. So developers don't have to reinvent the wheel. Said plugin is well thought out and documented and makes it quite easy to achieve what you want. All you need is a container with your posts and a link to the next page. The rest is taken care of by the plugin. Of course, you could spend hours and write the JS by yourself. I'd rather honor desandro's work and give him 25 bucks for a dev license. Already done it because I needed it for a custom template of a WP site some years ago. If you want to code the JS functionality yourself for whatever reason, you can certainly do that and and have fun with it. You should take browser history into account for usability reasons. The plugin does that. If you decided to use that plugin, setting up the markup and JS initialization could look somewhat like this (simplified example) /** @var PaginatedArray $newspages */ $newspages = $pages->find("template=newsitem, limit=12"); /** @var string $nextPageUrl typically something like /newspage/page2 */ $nextPageUrl = $page->url . $input->pageNumStr((int) $input->pageNum() +1) ?> <div class="infinitescroll"> <?php foreach($newspages as $p) { ?> <article class="post">...</article> <?php } ?> </div> <a href="<?= $nextPageUrl ?>" class="pagination__next">Next page</a> <script> let elem = document.querySelector('.infinitescroll'); let infScroll = new InfiniteScroll( elem, { // options path: 'newspage/<?= $config->pageNumUrlPrefix ?>{{#}}', append: '.post', history: false, // or true }); </script> I have not tested this example code but it should get you started.
  2. Coming here 4 years later because the problem still seems to appear in PW3.0.208 dev and the proposed workarounds are not working for me. I tried both hooks in Pages::find and ProcessPageSearch::findReady. Even if I uncomment the if statements in https://github.com/processwire/processwire/blob/6018c1fbc41c5aab4aceedf1d4a9c610de34aff3/wire/modules/Process/ProcessPageSearch/ProcessPageSearch.module#L378 and https://github.com/processwire/processwire/blob/6018c1fbc41c5aab4aceedf1d4a9c610de34aff3/wire/modules/Process/ProcessPageSearch/ProcessPageSearch.module#L390 Unpublished pages are still not selectable from autocomplete fields for non superusers. Kind of frustrating. And no idea how else to tackle this. Any help would be much appreciated. Need to switch to InputfieldSelectMultiple InputfieldAsmSelect which is not so nice since there will be ~50 pages from which to select.
  3. This is working great. Thank you. Actually I had added it to the JSON before inside a migration method for MM settings. Since MM stores it's settings not as ModuleConfigData but as custom JSON, I had to come up with a method in our migration class that keeps the settings in sync between dev and live. Just in case anybody needs this, here is what I did: /** * apply settings to MediaManager */ private function applyMediaManagerSettings() { $path = $this->wire('config')->urls->admin . 'media-manager/'; $selector = "template=media-manager-settings, status<" . Page::statusTrash; if (!$this->wire('modules')->isInstalled('PagePaths')) $selector .= ", parent={$path}"; $settingsPage = $this->wire('pages')->get($selector); $settingsRaw = $settingsPage->media_manager_settings; $settings = wireDecodeJSON($settingsRaw); //allowed media types $settings['allowed_media'] = ['media' => [/* "audio", */"document","image","video"]]; // Add uploads to media library and publish them $settings['after'][0] = 1; // show filter profiles: yes $settings['show_filter_profiles'] = [1]; // Display User Media: Display all Media $settings['user_media_only'] = [1]; // Sort Media By: Created $settings['sort_media'] = [4]; // Sort Media Order: Descending $settings['sort_media_order'] = [2]; // custom columns in Media manager $imageFields = []; foreach (['products', 'clinical_applications', 'technologies', 'image_gallery'] as $field) $imageFields[] = $this->wire->fields->get($field)->id; $settings['custom_columns'] = array('image' => $imageFields); // filter profiles $settings['filters'] = [ "filter-by-tags" => ["defaultSelector" => "title%=, media_manager_image.tags~=, media_manager_document.tags~=, media_manager_video.tags~=", "title" => "Filter by Tags"], ]; // save settings $settingsPage->of(false); $settingsPage->media_manager_settings = wireEncodeJSON($settings); $settingsPage->save(); }
  4. Hello @kongondo, I have added a checkbox field to the media-manager-image template but cannot choose it as a custom column. Guess this matter is about supported field types for custom columns. Fieldtype Checkbox seems not to be supported. It is supported in normal listers, though. Would it be possible to add support? And is there a list of the supported field types? EDIT: If I add the field id manually to the MM settings JSON, the column appears in the image lister, but not in the Settings ASM Select
  5. Hi all, I was playing around with background video clipped by text to get a nice text effect like https://codepen.io/gebeer/live/wvxweZX In that process I was brushing up knowledge about best compression options for html5 video and came across this very concise article that sums it all up: https://www.kaels-kabbage.com/posts/html5-video-and-images-for-web/ The video in my codepen is 1920x188px 30 seconds at 30fps. The results I got with h264 codec are already pretty good. But with AV1 it is much better. Comparison: original uncompressed: 3.2MB h264 codec: 568KB AV1 codec: 258KB I used Handbrake (ffmpeg) for encoding. For comparison I also tried several cloud services and found https://convertio.co/av1-converter/ to be the most versatile.
  6. I would not have expected this since the lib is actively maintained and used by many projects. But in the github issues I saw that the author seems to be working on PHP 8 support. Most things we can do with CSS/JS but if you want to deliver completely different content for mobile devices, doing it on the PHP level is a viable option. Caching is a problem, though and needs some extra attention. Personally I would solve this through img srcset and size attributes. No need for separate code here.
  7. @snck I am currently working on implementing Repeater Matrix support. It is basically working but needs some more thorough testing. ATM the setMatrixItems() method seems to be working well. If you like, you can grab a copy from https://github.com/gebeer/RockMigrations/tree/repeatermatrix and test it out. This is how you create a Repeater Matrix field: // first create the blank field $rm->createField('repeater_matrix_test', 'FieldtypeRepeaterMatrix', ['label' => 'Product Content Blocks', 'tags' => 'products']); /** * Set items (matrixtypes) of a RepeaterMatrix field * * If wipe is set to TRUE it will wipe all existing matrix types before * setting the new ones. Otherwise it will override settings of old types * and add the type to the end of the matrix if it does not exist yet. * * CAUTION: wipe = true will also delete all field data stored in the * repeater matrix fields!! */ $rm->setMatrixItems('your_matrix_field', [ 'foo' => [ // matrixtype name 'label' => 'foo label', // matrixtype label 'fields' => [ // matrixtype fields 'field1' => [ 'label' => 'foolabel', // matrixtype field options 'columnWidth' => 50, // matrixtype field options ], 'field2' => [ 'label' => 'foolabel', // matrixtype field options 'columnWidth' => 50, // matrixtype field options ], ], ], 'bar' => [ // matrixtype name 'label' => 'bar label', // matrixtype label 'fields' => [ // matrixtype fields 'field1' => [ 'label' => 'foolabel', // matrixtype field options 'columnWidth' => 50, // matrixtype field options ], 'field2' => [ 'label' => 'foolabel', // matrixtype field options 'columnWidth' => 50, // matrixtype field options ], ], ], ], true); Still need to test the other methods for removing/adding items etc. But this one should work. At least it was working in my tests. When testing is completed I will make a PR so @bernhard can implement.
  8. Hi all, we are moving a site from TYPO3 to PW. The old site has all URLs end in .html. Is there a simple way to achieve this in PW without breaking things like urlSegments, pagination etc. ? It might be doable with a hook to Page::path but I think that will break urlSegments. Maybe instead of trying to achieve that goal it might be better to implement redirects. Has anyone done this before? Would be great to hear your opinions/experiences.
  9. I wouldn't rely on this regex for mobile detection. There's a great library for that: https://github.com/serbanghita/Mobile-Detect You can simply copy the MobileDetect.php to site/templates/inc/MobileDetect.php. (If you prefer, you could install it via composer) And then include it in _init.php and use it like include_once('./inc/MobileDetect.php'); function isMobileDevice() { $detect = new \Detection\MobileDetect; return $detect->isMobile(); }
  10. Sorry, my fault. Try $item->colwidth->value
  11. To me this looks like a redirect issue. Thing is, that $_FILES gets cleared when POST requests are redirected. You can check for redirects in your browser dev tool's network tab when you submit the form. If you use the exact same form for both submissions (company and employee), you need to check what is different when you submit the form. Is the form action URL for both exactly the same? Do you have any code in place that redirects the form submission to a different URL when using it for employee?
  12. I'd go with FieldtypeOptions. Let's say your field is called "colwidth" and your options are: 1=1 2=2 3=3 Then you could do something like <?php $w1 = $page->colwidth; $w2 = 4 - $w1; ?> <div uk-grid> <div class='uk-width-<?= $w1 ?>-4@m uk-width-1-1@s'> <figure> <img src='{$page->image->url}' alt=''> </figure> </div> <div class='uk-width-<?= $w2 ?>-4@m uk-width-1-1@s'> $page->body </div> </div>
  13. Yes, you can use https://processwire.com/blog/posts/processwire-3.0.74-adds-new-fieldsetpage-field-type/ exactly for that so you can reuse other fields inside the FieldsetPage fields. Think of repeaters without repeating 🙂
  14. Love them. But too heavy for me while programming. I like light background music that helps me concentrate https://www.youtube.com/user/StudyMusicProject
  15. Hello and welcome to the forum! your question is related to a 3rd party module https://processwire.com/modules/markup-processwire-photoswipe/ On the module page you can see a link "Support" which links to the dedicated forum thread for that module. You might want to ask your question there. Besides that, the module has last been updated 6 years ago. So it uses an old version of the https://photoswipe.com/ script and might not be compatible with the latest ProcessWire version. In general, 3rd party modules are maintained by their authors and it is up to them whether they update them and offer support. It is up to youwhether you want to use and rely on a module with outdated code. After having a quick look at the module code, there is no easy way of bringing in the page title into the markup through the available render options. Like stated in the module documentation, you would have to extend the MarkupPwpswpGallery class. Alternatively you could edit the module code directly to achieve what you want. For a start have a look at https://github.com/blynx/MarkupProcesswirePhotoswipe/blob/a7c495964262f30eb28e891437665913ea5c5164/MarkupPwpswpGallery.module#L162 following and https://github.com/blynx/MarkupProcesswirePhotoswipe/blob/a7c495964262f30eb28e891437665913ea5c5164/MarkupPwpswpGallery.module#L196 following.
  16. Hello all, there are some older posts about nginx configuration for PW like @LostKobrakai created a gist. We have some sites in production on apache with nginx reverse proxy. One of those is receiving webhooks from snipcart. And in some situations the POST requests from snipcart are redirected through nginx and the POST request body data gets lost in this process. We are receiving those requests in apache with headers like where "HTTP_X_HTTP_METHOD_OVERRIDE": "POST" is sent like this by snipcart ... "REQUEST_METHOD": "GET", "HTTP_X_HTTP_METHOD_OVERRIDE": "POST", "QUERY_STRING": "it=/webhooks/snipcart/&", ... file_get_contents('php://input'); is null in those cases. After doing some research I found it could be related to the location / { try_files $uri $uri/ /index.php?it=$uri&$args; } directive in the nginx vhost.conf. I couldn't find the reason for the nginx redirect since the POST request is going to an existing endpoint /webhooks/snipcart/ (with trailing slash) and making test requests with POSTMAN didn't result in redirects. Has anyone else experienced this behaviour and knows a solution?
  17. I think it is totally ok to instantiate the script multiple times within the foreach.
  18. You have this div inside a foreach. Which means that you get multiple div#container in your HTML which will not validate and might cause problems with JS. You can add unique ids to the id with something like div id="container-<?= $book->id ?>" and see if that helps.
  19. Frontend forms in general would be a good topic. There's so much to find scattered around the forum but still people seem to struggle with it, especially when it comes to frontend file uploads with WireUpload.
  20. That sounds like a good way to approach it.
  21. Sounds great. There are some PW video tutorials out there. But nothing structured or consistent like you are planning to do. Do you mean that others can contribute videos as well? You could use a platform like https://www.codecademy.com/ to publish your courses. Will propably reach a broader audience than a custom made solution. concept of "everything is a page" structuring content working with templates/fields in the admin different output strategies: delayed, MarkupRegions etc PW as headless CMS with https://processwire.com/modules/app-api/ or https://processwire.com/modules/process-graph-ql/ I wouldn't concentrate too much on that because there are tons of tutorials out there already and PW is flexible enough to let devs implement frontend stuff in so many ways. But the basics of where you can place your source files, and how to include assets in template files might be helpful. Go for it and good luck!
  22. Looking at the RepeaterMatrixPage render() method for v0.0.8, you can pass in a file path that will be used for rendering. In the DocBlock for that method it says: "* @param string $file Optional render file, if providing a field name too". But looking at the code, it actually does not require to pass a field name in order to pick up the $file param. So inside your foreach you can implement some logic based on user role and page to pass in a custom render file /** @var RepeaterMatrixPage $item */ foreach($page->items as $item) { $renderFile = ($item->getForPageRoot()->foo == 'bar' && $user->hasRole('baz')) ? '/path/to/custom/renderfile.php' : ''; echo $item->render('', $renderFile); }
  23. @Gideon So you posted just seconds before me 🙂
×
×
  • Create New...