Jump to content

a-ok

Members
  • Posts

    812
  • Joined

  • Last visited

Everything posted by a-ok

  1. 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 http://159.65.162.128/products/ -vvv * Trying 159.65.162.128... * TCP_NODELAY set * Connected to 159.65.162.128 (159.65.162.128) port 80 (#0) > GET /products/ HTTP/1.1 > Host: 159.65.162.128 > 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 159.65.162.128 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?
  2. 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?
  3. 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?
  4. 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); });
  5. 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?
  6. 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 ?
  7. Thanks! Yes I know barba.js but surely I’d have the same issue with updating menus/content outside of what’s changing?
  8. 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 ?
  9. 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.
  10. Anyone? Am I wrong in thinking that the variations would be smaller in filesize? The original is 2000px wide so there’s no upscale.
  11. Not to my knowledge. I have this in my config.php file: $config->imageSizerOptions('sharpening', 'none'); $config->imageSizerOptions('quality', 100); $config->imageSizerOptions('defaultGamma', -1); And yes just a test ?
  12. I'm resizing my images for img srcset using a helper function: function getSrcsetImages($image, $variations, $sizes) { $srcset = array(); if (empty($variations)) { $srcsetSizes = array(100, 200, 300, 400, 500, 640, 750, 828, 1024, 1125, 1242, 1280, 1400, 1500, 1600, 1700, 1800, 1920); } else { $srcsetSizes = explode(", ", $variations); } foreach ($srcsetSizes as $s) { if ($s <= ceil($image->width())) { $srcset[] = $image->width($s)->url() . " {$s}w"; } } $srcset = implode(", ", $srcset); echo "src=\"{$image->url}\" data-srcset=\"{$srcset}\" sizes=\"{$sizes}\""; } <img <?php getSrcsetImages($image, null, "auto"); ?> class="--lazy" /> This works in theory but in my assets folder why are the variations, on average, larger than the original? Feels like I should just use one image at this point? Any thoughts on what I'm doing wrong?
  13. Just tried it! Works! Thank you! Including the template in the hook method... is this a new thing?
  14. Is it possible to skip the Page Add step when creating a child page that fills in both the title and name? I've used the template specific setting https://processwire.com/docs/modules/guides/process-template/ but this still requires the user to set a title. Any thoughts? I thought about using a hook https://processwire.com/talk/topic/13058-set-page-title-automatically/ but this doesn't skip the Page Add step.
  15. Does anyone know what sanitising the images get? I thought `$sanitizer→filename` but then it doesn't lowercase them?
  16. Thanks everyone. Do you think it's possible to filename sanitize a folder of images on my local? I'm guessing that's what @Robin S meant when he said: I'll look into it!
  17. Thanks so much, @Robin S Using Automator for Mac I'm going to open a finder file (the .csv) then run a bash script that would create a folder for each ID and move the corresponding image to that folder. A folder can have multiple images. As the DB is all intact it’s only the image links that are missing so this, in theory, should work. I just need to run something on all the images to sanitize them as PW did when the user uploaded them. Would you say using the API, as you’ve kindly shared, is a better approach and more effective and fool proof? My bash script: cd "${1%/*}" while read line do FolderName=${line%,*} ImageName=${line#*,} mkdir "$FolderName" mv "$ImageName" "$FolderName" done < "$1"
  18. This is slightly related to PW but also in need of some advice/help. I stupidly accidentally managed to rm -rf the LIVE assets folder on a site that has over 2 years worth of data. Let's not go there. I had a cronjob set up every night to back everything up (and keep the latest 7) but the .tar.gz files all error out with truncated tar archive and unexpected end of file I've managed to export off the image fields from the database as .csvs and my plan would be to combine them all into one .csv where you have two columns (ID and image filename). I then have a large unorganised dump of ALL the images but they: Haven't had their filenames sanitised by the PW uploading and Are all in one directory and thus not attached to any page ID My question is... how likely do you think it would be to use PW's API to: Sanitise all the filenames in a directory (and if anyone knows what type of sanitising images use) and Execute some sort of query (I'm on OSX) that would match the filename in the CSV with the filename in a directory (the image dump) and move the image to that folder with the same ID (this is a long shot) Any advice is appreciated.
  19. I've decided to disable it, run the process, then re-enable it. As there is quite a lot of pages to create (200) with multiple images per page is there a best practice/method you would suggest in order to run this?
  20. Okay. Bit of success! I had been using module 'ProcessCustomUploadNames' but when I disabled this it seemed to work fine and the images stayed! Any thoughts?
  21. Thanks, @bernhard – I did this and it added the images (visible in the folders within assets) but upon visiting it in the backend they were removed with the same message 'Pageimages: Removed 'images' temp file(s) for..'
  22. If I use TracyDebugger and run this: $page->of(false); $page->images->add("https://66.media.tumblr.com/f4958343844738fa507dc53d6493c988/tumblr_pszpc6YZF51uoauero1_1280.png"); $page->save(); It works fine ?
  23. @psy Many thanks for the help. It doesn't seem to make a difference unfortunately. Hmm...
×
×
  • Create New...