Jump to content


  • Content Count

  • Joined

  • Last visited

Community Reputation

73 Excellent

About a-ok

  • Rank
    Hero Member

Profile Information

  • Gender
    Not Telling

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. I'm attempting to include some code in the head.inc file that will check if the page is available in the user's location language and if so it'll redirect to that page. Obviously this isn't a great for UX but alas my client is keen. The only issue I need to overcome is if the user has already been redirected then don't do it for every page... store the fact that the user was redirected and don't do it again until the session has ended. Something like that. I have written the code below but a) I'm unsure this is the best way to do it and b) it seems to get stuck in a redirect loop (which I thought I'd avoided by my second session check). I'm using the ipapi.com to check the user's location. Any thoughts? if (!$session->get("lucentLightingRegion")) { bd($page->ipapiGetUserLocation()); $session->set("lucentLightingSessionRedirected", "false"); if ($page->ipapiGetUserLocation()['continent_code'] === 'NA') { $session->set("lucentLightingRegion", "NA"); if ($page->viewable('na')) { $url = $page->localUrl('na'); $session->redirect($url); } } else { $session->set("lucentLightingRegion", "INT"); if ($page->viewable('default')) { $url = $page->localUrl('default'); $session->redirect($url); } } } else { $sessionRegion = $session->get("lucentLightingRegion"); bd($sessionRegion); if ($page->viewable($sessionRegion) && $session->get("lucentLightingSessionRedirected") == "false") { $url = $page->localUrl($sessionRegion); $session->redirect($url); $session->set("lucentLightingSessionRedirected", "true"); } }
  2. I've attached some images. I'm assuming it's an LCN server issue but they've stated they don't limit/cap anything. Same file on localhost and a DigitalOcean server upload fine whereas on LCN it jumps to 600kb and effectively breaks the file.
  3. If I'm uploading a .mp4 (could potentially be any file) to a file upload field and the file is 3mb but on uploading the file is 600kb and then the .mp4 is glitchy/plays for only a few seconds (in the browser) is it safe to assume something wrong is set on the server? I've never had this issue before (use DigitalOcean, mainly) but I'm using LCN for a client and this issue has only just occurred since migrating from my dev to LCN. Any thoughts?
  4. I just fixed it. Turns out `sudo a2enmod rewrite` wasn't enabled 🤨FOUR HOURS LATER. Sorry for wasting everyone's time.
  5. I know these posts have been created a lot and I've trawled through a bunch and can't seem to find a solution for my current problem. I moved a PW site from my own DigitalOcean droplet > it's own Droplet and the homepage works fine but every other page gets stuck in a 301 redirect loop. I used curl to debug it a bit: curl -vvv * Trying * TCP_NODELAY set * Connected to ( port 80 (#0) > GET /products/ HTTP/1.1 > Host: > User-Agent: curl/7.54.0 > Accept: */* > < HTTP/1.1 301 Moved Permanently < Date: Tue, 12 Nov 2019 12:03:55 GMT < Server: Apache/2.4.41 (Ubuntu) < Expires: Thu, 19 Nov 1981 08:52:00 GMT < Cache-Control: no-store, no-cache, must-revalidate < Pragma: no-cache < X-Powered-By: ProcessWire CMS < Set-Cookie: wire=de9ifnvlqr75l546fg66a1tkrd; path=/; HttpOnly < Upgrade: h2,h2c < Connection: Upgrade < Location: /products/ < Content-Length: 0 < Content-Type: text/html; charset=utf-8 < * Connection #0 to host left intact And in the Network tab in Chrome it seems to just keep redirecting to the same page and then eventually errors out. My .htaccess file is exactly how it was on the other DigitalOcean droplet and I have no idea where to go to now. I don't have any SSL set up yet either so no modifications to any vhosts files. Any immediate thoughts or has anyone had this issue before?
  6. I changed the PHP version from 7.2 to 7.1 and the errors were 'silenced' based on the answer here > https://stackoverflow.com/questions/47700336/php-7-2-warning-cannot-change-session-name-when-session-is-active Is this something that should be reported on PW's Github?
  7. I'm getting the following errors on all pages of a site I've built. I had just cleared/deleted the sessions folder on the server which solved this but now it's come back. Any thoughts?
  8. Many thanks for this, @Mats var request = new Request(url, { headers: new Headers({ 'X-Requested-With': 'XMLHttpRequest' }) }); fetch(request) .then(response => response.text()) .then(data => { console.log(data); });
  9. Quick one. When using JS fetch() rather than jQuery's $.ajax, in my templates if (!$config->ajax) include $config->paths->templates . "head.inc"; seems to be ignored and it returns the head.inc in the response. Am I missing something?
  10. Page transitions etc and I guess barba is just an alternative to that. I see what you’re getting at but as I’d still have this issue with barba then the issue still stands 🙃
  11. Thanks! Yes I know barba.js but surely I’d have the same issue with updating menus/content outside of what’s changing?
  12. I'm looking for some best practice advice. A standard setup for me is to have a head.inc and a foot.inc and then everything in-between is updated via AJAX calls with some transition. Getting a bit boring but that's currently how it is. The issue I have is most of the time the main site nav/menu, which is in the head.inc, is contextual and will change based on the page being view. This can cause a lot of duplication of code as 1) I write it with PW in PHP so if the page is visited directly it is reflected and 2) I also have to do the same in JS if the page is visited via an AJAX call. You see the dilemma. What I've started to do recently is build a PHP array in an include file for the menu, and also `json_encode` it so I have an array, of the same code, one for PHP to use and one for the JS to use. Something like the below... $menuArray = array(); $menuLeft = $pages->find("template=work|news, sort=sort"); $menuRight = $pages->find("template=clients|about, sort=sort"); if ($page->id !== 1) { $menuLeft->filter("id={$page->id}"); $menuRight->filter("id={$page->id}"); } foreach ($menuLeft as $item) { $menuArray['left'][] = array( 'id' => $item->id, 'name' => $item->name, 'url' => $item->url, 'title' => $item->title, 'x' => '100%' ); // If current page then prepend 'Close' if ($page->template->name == $item->name) { array_push($menuArray['left'], array( 'name' => 'close', 'url' => $pages->get(1)->url, 'title' => 'Close', 'x' => '100%' )); } } foreach ($menuRight as $item) { $menuArray['right'][] = array( 'id' => $item->id, 'name' => $item->name, 'url' => $item->url, 'title' => $item->title, 'x' => '100%' ); // If current page then append 'Close' if ($page->template->name == $item->name) { array_unshift($menuArray['right'], array( 'name' => 'close', 'url' => $pages->get(1)->url, 'title' => 'Close', 'x' => '100%' )); } } // Return JSON for JS (PHP can grab $menuArray directly) $menuJSON = json_encode($menuArray); if ($config->ajax) { echo '<script id="menuJSON">'; echo "menuJSON = {$menuJSON}"; echo '</script>'; } Then in the head.inc loop through `$menuArray` and in the JS loop through, on AJAX changes, `menuJSON`. updateMenu: function(e) { var $header = document.querySelector('header.main'), headerContent = ''; for (var menu in menuJSON) { headerContent += '<ul class="menu --' + menu + '">'; menuJSON[menu].forEach(function(item) { headerContent += '<li data-template-name="' + item.name + '"><a data-ajax data-x="' + item.x + '>" href="' + item.url + '">' + item.title + '</a></li>'; }); headerContent += '</ul>'; } $header.innerHTML = headerContent; } The issue I'm having is I have no idea if this is the best way to work with something like this and wondered if anyone had any input? It also feels weird echo'ing out script tag with PHP then relying on the JS finding it in the DOM. You know? Anyway... I'll put this out there and see what happens 🙂
  13. Thanks, @Robin S The original is saved at JPEG quality 8 in Photoshop. Anything less than 100 in PW, in my experience, messes with the colours so always have to keep it at 100.
  14. Anyone? Am I wrong in thinking that the variations would be smaller in filesize? The original is 2000px wide so there’s no upscale.
  • Create New...