• Content Count

  • Joined

  • Last visited

  • Days Won


gebeer last won the day on March 26

gebeer had the most liked content!

Community Reputation

764 Excellent

About gebeer

  • Rank
    Distinguished Member

Profile Information

  • Gender
  • Location

Recent Profile Visitors

7,718 profile views
  1. Great idea, thank you @bernhard I tried your solution, added a new child page under Admin with name 'my-profile' and assigned the ProcessUser process. When I go to that URL, I get a list of users. When I click on one of the users' name, I get to an URL like .../my-profile/edit/?id=1020 and am on the user edit screen. I need to avoid the first step and go right to the second while still having only '.../my-profile' in the address bar, without the edit/?id=xxx. But your hook is a great way of securing my current setup! Another thing I tried some time ago: In my custom user dashboard which is a process module, I have a method public function ___executeMyprofile() { $processUser = $this->modules->get('ProcessUser'); return $processUser->executeEdit(); } But this never worked because there are some wired in redirects in place, that always redirect to the .../access/users/edit/?id=xxx URL. At that time I even opened a thread on this topic which was never resolved.
  2. Thank you @Robin S for looking into this. My question was: how can I make a user edit screen under a URL like '/adminurl/access/users/edit/?id=1377' available under a URL like '/adminurl/myprofile/'. So that all user edit URLs with different user ids are routed to that 'myprofile' URL and the users that edit their user pages (which are their profiles in my case) never sees the actual user id and cannot try to mess with it. Thus I chose the term 'mask' in the thread title. Maybe the way I explained it was confusing or not clear. I am not using the default user template but my own user template. User pages live under their own parent ( Users can edit their pages via the page edit process. This is working fine. I just need to change (mask) the URL for that process. The 2 ways that I can think of for approaching this: make the user edit process available under a custom process module which resolves to '/adminurl/myprofile/' have some htaccess rewrite magic in place I'd prefer number 1, as I cannot easily adjust the htaccess rules so that they only kick in for the custom user type and not for all ''/adminurl/access/users/edit/?id=1377' type of URLs. Hope this clears things up a bit
  3. gebeer

    Hello @apeisa, thank you for this module. I use it on many sites. Now I have a client site where the homepage in the default language has a url segment 'de'. In the LanguageSupportPageNames module I have the setting active to redirect the default language pages to that url segment. So the homepage URL in the default language reads ''. In my opinion this setup does not make a lot of sense but the client insisted, so what can I do.... Now when I add a redirect like '/wer-wir-sind' (which is an old URL from the pre-PW site), the module does not kick in because the LanguageSupportPageNames module adds the 'de' to the URL. Now I end up with a URL like '''. The redirects module cannot find that URL and won't redirect. As a workaround, the administrator could enter redirects for the default language in the format '/de/wer-wir-sind'. Now redirects work but from a logical point of view this doesn't make sense. Because we want to redirect from'' to a chosen URL and not from ''. To make a long story short: I added some code to the checkRedirects method of the module right after line 247, which caters for this special use case: // if homepage in default language has a language segment and the root URL is redirecting to that language segment, // remove the segment from the url so it can be found in the DB if( $this->wire('modules')->isInstalled('LanguageSupportPageNames') && $this->wire('modules')->getModule('LanguageSupportPageNames')->useHomeSegment && $this->wire('user')->get('language')->isDefault() ) { $homeSegment = '/' . $this->wire('pages')->get(1)->name; if (substr($url, 0, strlen($homeSegment)) == $homeSegment) { // remove the language segment from $url so it can be found in the DB $url = substr($url, strlen($homeSegment)); } } If you think it should be implemented into your module, let me know and I'll make a PR on github. Cheers
  4. Hello, I have a user page template with many fields that are organised in tabs. Tabs do not work on the profile edit screen. So I had to find a way how to let users edit their page with tabs in place. The way I solved this is having users edit their user page in the backend instead of their profile page. So basically they are on a page edit screen and not on their profile edit screen which is a different process. The drawback of this method is that the users edit their profile on a URL like .../youradminurl/access/users/edit/?id=1377. So I needed to make sure that users cannot edit other users' profiles by just switching out the id. I did this through hooks that redirect them to their own profile. This is far from a perfect solution. Ideally I would like to mask the page edit url to something like /myprofile but haven't found a way on how to do this, yet. How would you go about this? redirect rules in .htaccess hooking into the profile edit process? Either way I couldn't figure out how to accomplish it. Any pointers towards a solution would be very much appreciated.
  5. Very nice writeup. Thank you for sharing! There are so many different approaches to handling responsive images and it is great to see how others do it. Would love to see more approaches from others here, too. To get the concept of responsive images, I read the anatomy of responsive images which explains them very well. Then I used to implement a quite similar approach to @MoritzLost for some time utilizing the MarkupSrcset module and also my own functions. Until I stumbled upon an article about creating responsive images which shows an approach that I now prefer. In this approach you go through all your different images in the finished layout and determine their exact respective size at your breakpoints. Then you build srcset and sizes attributes for those exact values. So there is no more approximation using scaling factors. You get exactly the amount of images at the sizes you need them. I pass an array with the breakpoints and the required sizes for that breakpoint and build srcset and sizes from that array. Here's the code: /** * Builds responsive img tag with srcset and sizes attributes * @param \Processwire\Pageimage $img * @param array $breakpointsizes array of associative arrays that describe media min breakpoints and width/height of images from the respective * breakpoint to the next * Example: * $breakpointSizes = [ * ['bp' => 320, 'sz' => [500, 0]], * ['bp' => 576, 'sz' => [992, 0]], * ['bp' => 992, 'sz' => [690, 0]] * ['bp' => 1200, 'sz' => [835, 0]] * ]; * @return string */ function renderImageResponsive($img, $breakpointSizes) { $imgSrc = $img->url; // use original image as fallback src $alt = ($img->description) ? $img->description : $img->page->title; // if no description use page title // construct sizes attribute $sizes = array(); foreach(array_reverse($breakpointSizes) as $bs) { $sizes[] = "(min-width:{$bs['bp']}px) {$bs['sz'][0]}px"; } $sizes = implode(', ', $sizes) . ', 100vw'; // construct srcset attribute $srcSet = array(); foreach($breakpointSizes as $bs) { $srcSet[] = $img->size($bs['sz'][0], $bs['sz'][1])->url . " {$bs['sz'][0]}w"; } $srcSet = implode(', ', $srcSet); return "<img class='img-fluid' src='{$imgSrc}' srcset='{$srcSet}' sizes='{$sizes}' alt='{$alt}'>"; } Obviously it does not account for Retina which needs to be added. I will also extend my function to add support for other attributes like you showed it. That is a great idea.
  6. gebeer

    @thomasaull Great that you are converting this into a module. It would be a muc better fit. That way we can add api funtionality to any site easily. Actually, I was thinking about converting your site profile to a module, too
  7. gebeer

    Hallo, I wanted to test this site profile and cloned PW 3.0.98 from git. Then cloned the site profile repo and installed PW without any issues. I issued the 2 composer commands to install dependencies. Environment: Apache with PHP 7.0.29 FPM/FastCGI. When I try to access api/test, I get the following error Looks like a namespace issue. I didn't change namespaces on any of the files included in the profile. My config.php is not namespaced. Does anyone have an idea how I can overcome this? EDIT: apache_request headers became available under FastCGI since 5.4.0 according to EDIT2: After some more investigation I found So it seems apache_request_headers is still not supported in PHP 7.0 FPM/CGI environment. I added templates/inc/functions.php with contents of and added require "{$config->paths->templates}inc/functions.php"; to api.php This solved the problem :)-
  8. gebeer

    I ran into a similar issue with v1.1.0. using Javascript Loading method: Load file to $config->scripts emo.min.js is included on the page before the <!-- emo --> script block which defines var emo_addr. The function emo_replace() never gets called because at the point of script inclusion emo_addr === undefined. In v1.5 of emo.js window.onload was removed. So the script never executes when emo.min.js is included before the <!-- emo --> script block. I have refactored emo.js as an object literal and modified the module Code so that the script block calls emo.init(emo_addr) after defining the addresses. Tested without problems. Modified module can be found at @Roope do you want a PR for that?
  9. gebeer

    I've been following the discussion about language translation for this module. It is convenient to edit the language specific texts on the module settings page. But if they were implemented as i18n language translation strings, I guess all those problems would be solved. I personally wouldn't mind to edit those under Settings->Languages as long as there is a hint on the module settings page.
  10. gebeer

    Hello, I just installed this module on PW 2.7.2. On the module settings page I get an error "Call to a member function render() on a non-object" from line 78 of CookieManagementBanner.module. $this->wire('files') is null. If I replace line 78 with the following, everything works ok. $cookieBanner = wireRenderFile($this->wire('config')->paths->$this.'wrapper.tpl.php', array('module' => $this, 'lang' => $lang)); Seems like wire('files') is not available in 2.7.2 which is strange. Can anyone confirm this?
  11. gebeer

    Anyone interested in the module with added region option and with added o:deliverytime option can use my fork at
  12. gebeer

    @cb2004 attached is an amended version of the module and module config. I added a setting for the region and the API URL will adjust accordingly. WireMailMailgunConfig.php WireMailMailgun.module
  13. gebeer

    Could you please share a link to the mailgun docs where this is mentioned. Thank you. EDIT: Never mind. I found it:
  14. From the API side it is still valid and working code. I don't think there is one best way to go. This tutorial shows one possible approach. There are many different other approaches possible. But at least it shows the basics of implementing a REST API. You can also have a look at which is the most recent approach I'm aware of.
  15. gebeer

    @Peter Knight What do you want to do with products that do not have images? In your foreach you define the $image variable only when there are images. Then you echo the images even if there are none. This will give you a PHP notice for $image is undefined. You'd need another if condition within your echo to check for isset($image) and only output the image if there is one. The way you setup your images field it should definitely return an empty array if there are no images so the if (count($prod->images)) should work as expected.