Jump to content

PWaddict

Members
  • Posts

    908
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by PWaddict

  1. To always display the map at the center even if the browser resized or the full screen button pressed just use the below function: google.maps.event.addDomListener(window, 'resize', function() { var center = map.getCenter() google.maps.event.trigger(map, "resize") map.setCenter(center) });
  2. Here is my best solution so far. Now, when I click on the "a:not(.external)" links the pages are always load with "scrollTop(0)" and when I use the browser's back/forward buttons "popstate" I always get the saved scroll position. There is only 1 tiny problem with the "popstate". Once I press the browser's back/forward buttons I get instantly the saved scroll position on the current page and then the page gets replaced with the correct one. How can I make it to get the scroll position ONLY when the page gets replaced and not before? $(function() { $(document).on('click', 'a:not(.external)', function(e) { var replacePage = function(url) { $.ajax({ url: url, type: 'get', dataType: 'html', success: function(data) { $(window).scrollTop(0); var dom = $(data); var title = dom.filter('title').text(); var html = dom.filter('.ajax-container').html(); $('title').text(title); $('.ajax-container').html(html); } }); }; history.pushState(null, null, this.href); replacePage(this.href); e.preventDefault(); }); $(window).on('popstate', function() { var replacePagePopstate = function(url) { $.ajax({ url: url, type: 'get', dataType: 'html', success: function(data) { var dom = $(data); var title = dom.filter('title').text(); var html = dom.filter('.ajax-container').html(); $('title').text(title); $('.ajax-container').html(html); } }); }; replacePagePopstate(location.pathname); }); });
  3. @abdus It doesn't work and I don't know how to modify it but thanks anyway!
  4. There is only a small "downside" if the website is already online. All links from the default language (except homepage) will change so the Page Path History module MUST be installed to avoid 404 errors from previously shared pages, google search etc. Make sure to update your README.md with all these important info.
  5. @Mike Rockett nice "trick"! I don't remember seeing that option on LanguageSupportPageNames. I will definitely gonna use that. I'm currently using the language_iso_code field not only on my sitemap but also on site's navigation (hreflang) and the flag icons but I will delete it
  6. I'm currently using the Window Resizer Chrome extension.
  7. @Mike Rockett There are 3 problems with the module: 1. The iso for the default language as @maxf5 mentioned. 2. Some pages are completely ignored 3. Wrong sitemap markup. Each link must have it's alternate links not just the default one. I'm currently using the below method for a proper multi-language sitemap. 1st step Create a php file "sitemap-xml-multilanguage.php" with the below code and add it on /site/templates/ folder. <?php namespace ProcessWire; if (!wire('modules')->isInstalled('LanguageSupportPageNames')) throw new WireException('Missing module: LanguageSupportPageNames'); // Exclude pages here function selectors() { $selectors = array( '', // E.g. template!=variations ); return implode(',',$selectors); } function renderSitemapPage(Page $page) { $out = ''; foreach (wire('languages') as $lg) { if (!$lg->isDefault() && !$page->{"status$lg->id"}) continue; $out .= "\n<url>" . "\n\t<loc>" . $page->localHttpUrl($lg) . "</loc>" . renderSitemapAlternateLangs($page) . "\n\t<lastmod>" . date("Y-m-d", $page->modified) . "</lastmod>" . "\n</url>"; } return $out; } function renderSitemapChildren(Page $page) { $out = ''; $newParents = new PageArray(); $children = $page->children(selectors()); foreach($children as $child) { $out .= renderSitemapPage($child); if($child->numChildren) $newParents->add($child); else wire('pages')->uncache($child); } foreach($newParents as $newParent) { $out .= renderSitemapChildren($newParent); wire('pages')->uncache($newParent); } return $out; } function renderSitemapAlternateLangs(Page $page) { $out = ''; foreach(wire('languages') as $lg) { if (!$lg->isDefault() && !$page->{"status$lg->id"}) continue; $iso = $lg->language_iso_code; // Custom text field for ISO under system's language template $out .= "\n\t<xhtml:link rel=\"alternate\" hreflang=\"$iso\" href=\"".$page->localHttpUrl($lg)."\"/>"; } return $out; } function renderSitemapXML(array $paths = array()) { $out = '<?xml version="1.0" encoding="UTF-8"?><urlset xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xmlns="https://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="https://www.w3.org/1999/xhtml" xsi:schemaLocation="https://www.sitemaps.org/schemas/sitemap/0.9 https://www.sitemaps.org/schemas/sitemap/0.9/siteindex.xsd">'; array_unshift($paths, '/'); foreach($paths as $path) { $page = wire('pages')->get($path); if(!$page->id) continue; $out .= renderSitemapPage($page); if($page->numChildren) $out .= renderSitemapChildren($page); } $out .= "\n</urlset>"; return $out; } header("Content-Type: text/xml"); echo renderSitemapXML(); Note: The above code if I remember correctly is based on @ryan and @kixe code. 2nd step Add the new template "sitemap-xml-multilanguage" in PW and under URLs tab on "Should page URLs end with a slash?" select "No". 3rd step Create a new page under "Home" with the title "sitemap.xml" by using the "sitemap-xml-multilanguage" template. Final step Create a text field with the name "language_iso_code" and add it under system's language template under "Setup > Templates > Show system templates? > Yes. Then on each language under "Setup > Languages" you will have to add the iso name. This is useful for the default language. Here are the results I'm getting on http://localhost/mysite/sitemap.xml with my method: <urlset xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xmlns="https://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="https://www.w3.org/1999/xhtml" xsi:schemaLocation="https://www.sitemaps.org/schemas/sitemap/0.9 https://www.sitemaps.org/schemas/sitemap/0.9/siteindex.xsd"> <url> <loc>http://localhost/mysite/</loc> <xhtml:link rel="alternate" hreflang="el" href="http://localhost/mysite/"/> <xhtml:link rel="alternate" hreflang="en" href="http://localhost/mysite/en/"/> <lastmod>2017-09-02</lastmod> </url> <url> <loc>http://localhost/mysite/en/</loc> <xhtml:link rel="alternate" hreflang="el" href="http://localhost/mysite/"/> <xhtml:link rel="alternate" hreflang="en" href="http://localhost/mysite/en/"/> <lastmod>2017-09-02</lastmod> </url> <url> <loc>http://localhost/mysite/nea/</loc> <xhtml:link rel="alternate" hreflang="el" href="http://localhost/mysite/nea/"/> <xhtml:link rel="alternate" hreflang="en" href="http://localhost/mysite/en/news/"/> <lastmod>2017-08-27</lastmod> </url> <url> <loc>http://localhost/mysite/en/news/</loc> <xhtml:link rel="alternate" hreflang="el" href="http://localhost/mysite/nea/"/> <xhtml:link rel="alternate" hreflang="en" href="http://localhost/mysite/en/news/"/> <lastmod>2017-08-27</lastmod> </url> <url> <loc>http://localhost/mysite/parastaseis/</loc> <xhtml:link rel="alternate" hreflang="el" href="http://localhost/mysite/parastaseis/"/> <xhtml:link rel="alternate" hreflang="en" href="http://localhost/mysite/en/shows/"/> <lastmod>2017-08-07</lastmod> </url> <url> <loc>http://localhost/mysite/en/shows/</loc> <xhtml:link rel="alternate" hreflang="el" href="http://localhost/mysite/parastaseis/"/> <xhtml:link rel="alternate" hreflang="en" href="http://localhost/mysite/en/shows/"/> <lastmod>2017-08-07</lastmod> </url> <url> <loc>http://localhost/mysite/omada/</loc> <xhtml:link rel="alternate" hreflang="el" href="http://localhost/mysite/omada/"/> <xhtml:link rel="alternate" hreflang="en" href="http://localhost/mysite/en/meet-the-team/"/> <lastmod>2017-08-25</lastmod> </url> <url> <loc>http://localhost/mysite/en/meet-the-team/</loc> <xhtml:link rel="alternate" hreflang="el" href="http://localhost/mysite/omada/"/> <xhtml:link rel="alternate" hreflang="en" href="http://localhost/mysite/en/meet-the-team/"/> <lastmod>2017-08-25</lastmod> </url> <url> <loc>http://localhost/mysite/epikoinwnia/</loc> <xhtml:link rel="alternate" hreflang="el" href="http://localhost/mysite/epikoinwnia/"/> <xhtml:link rel="alternate" hreflang="en" href="http://localhost/mysite/en/contact/"/> <lastmod>2017-09-02</lastmod> </url> <url> <loc>http://localhost/mysite/en/contact/</loc> <xhtml:link rel="alternate" hreflang="el" href="http://localhost/mysite/epikoinwnia/"/> <xhtml:link rel="alternate" hreflang="en" href="http://localhost/mysite/en/contact/"/> <lastmod>2017-09-02</lastmod> </url> <url> <loc>http://localhost/mysite/nea/test-4/</loc> <xhtml:link rel="alternate" hreflang="el" href="http://localhost/mysite/nea/test-4/"/> <xhtml:link rel="alternate" hreflang="en" href="http://localhost/mysite/en/news/test-4/"/> <lastmod>2017-08-14</lastmod> </url> <url> <loc>http://localhost/mysite/en/news/test-4/</loc> <xhtml:link rel="alternate" hreflang="el" href="http://localhost/mysite/nea/test-4/"/> <xhtml:link rel="alternate" hreflang="en" href="http://localhost/mysite/en/news/test-4/"/> <lastmod>2017-08-14</lastmod> </url> <url> <loc>http://localhost/mysite/nea/test-3/</loc> <xhtml:link rel="alternate" hreflang="el" href="http://localhost/mysite/nea/test-3/"/> <xhtml:link rel="alternate" hreflang="en" href="http://localhost/mysite/en/news/test-3/"/> <lastmod>2017-08-11</lastmod> </url> <url> <loc>http://localhost/mysite/en/news/test-3/</loc> <xhtml:link rel="alternate" hreflang="el" href="http://localhost/mysite/nea/test-3/"/> <xhtml:link rel="alternate" hreflang="en" href="http://localhost/mysite/en/news/test-3/"/> <lastmod>2017-08-11</lastmod> </url> <url> <loc>http://localhost/mysite/nea/test-2/</loc> <xhtml:link rel="alternate" hreflang="el" href="http://localhost/mysite/nea/test-2/"/> <xhtml:link rel="alternate" hreflang="en" href="http://localhost/mysite/en/news/test-2/"/> <lastmod>2017-08-11</lastmod> </url> <url> <loc>http://localhost/mysite/en/news/test-2/</loc> <xhtml:link rel="alternate" hreflang="el" href="http://localhost/mysite/nea/test-2/"/> <xhtml:link rel="alternate" hreflang="en" href="http://localhost/mysite/en/news/test-2/"/> <lastmod>2017-08-11</lastmod> </url> <url> <loc>http://localhost/mysite/nea/test-1/</loc> <xhtml:link rel="alternate" hreflang="el" href="http://localhost/mysite/nea/test-1/"/> <xhtml:link rel="alternate" hreflang="en" href="http://localhost/mysite/en/news/test-1/"/> <lastmod>2017-08-11</lastmod> </url> <url> <loc>http://localhost/mysite/en/news/test-1/</loc> <xhtml:link rel="alternate" hreflang="el" href="http://localhost/mysite/nea/test-1/"/> <xhtml:link rel="alternate" hreflang="en" href="http://localhost/mysite/en/news/test-1/"/> <lastmod>2017-08-11</lastmod> </url> <url> <loc> http://localhost/mysite/parastaseis/test/ </loc> <xhtml:link rel="alternate" hreflang="el" href="http://localhost/mysite/parastaseis/test/"/> <xhtml:link rel="alternate" hreflang="en" href="http://localhost/mysite/en/shows/test/"/> <lastmod>2017-09-04</lastmod> </url> <url> <loc> http://localhost/mysite/en/shows/test/ </loc> <xhtml:link rel="alternate" hreflang="el" href="http://localhost/mysite/parastaseis/test/"/> <xhtml:link rel="alternate" hreflang="en" href="http://localhost/mysite/en/shows/test/"/> <lastmod>2017-09-04</lastmod> </url> </urlset> and here are the results from your module: <urlset xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xmlns="https://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="https://www.w3.org/1999/xhtml" xsi:schemaLocation="https://www.sitemaps.org/schemas/sitemap/0.9 https://www.sitemaps.org/schemas/sitemap/0.9/siteindex.xsd"> <url> <loc>http://localhost/mysite/</loc> <lastmod>2017-09-02T05:37:50+03:00</lastmod> <xhtml:link rel="alternate" hreflang="home" href="http://localhost/mysite/"/> <xhtml:link rel="alternate" hreflang="en" href="http://localhost/mysite/en/"/> </url> <url> <loc>http://localhost/mysite/parastaseis/</loc> <lastmod>2017-08-07T09:51:08+03:00</lastmod> <xhtml:link rel="alternate" hreflang="home" href="http://localhost/mysite/parastaseis/"/> <xhtml:link rel="alternate" hreflang="en" href="http://localhost/mysite/en/shows/"/> </url> <url> <loc> http://localhost/mysite/parastaseis/test/ </loc> <lastmod>2017-09-04T11:06:36+03:00</lastmod> <xhtml:link rel="alternate" hreflang="home" href="http://localhost/mysite/parastaseis/test/"/> <xhtml:link rel="alternate" hreflang="en" href="http://localhost/mysite/en/shows/test/"/> </url> <url> <loc>http://localhost/mysite/omada/</loc> <lastmod>2017-08-25T20:27:09+03:00</lastmod> <xhtml:link rel="alternate" hreflang="home" href="http://localhost/mysite/omada/"/> <xhtml:link rel="alternate" hreflang="en" href="http://localhost/mysite/en/meet-the-team/"/> </url> <url> <loc>http://localhost/mysite/epikoinwnia/</loc> <lastmod>2017-09-02T04:10:51+03:00</lastmod> <xhtml:link rel="alternate" hreflang="home" href="http://localhost/mysite/epikoinwnia/"/> <xhtml:link rel="alternate" hreflang="en" href="http://localhost/mysite/en/contact/"/> </url> </urlset> I hope it can help you fix your module.
  8. @horst @tpr After closing the modal the hover tooltip appears and it feels like a glitch cause it also half-cover the button preview. I fixed it by replacing the 34 line on InputfieldCroppableImage3.js with this: items: 'a:hover' Thank you very much guys for your work
  9. Works great. One small fix from me. After saving the page or revisiting it I'm seeing a previous cached icon-size thumb. This happening even on localhost. So, I fixed it by replacing the 155 line on InputfieldCroppableImage3.module with this: $out .= $warning ? '' : " <img src='{$pagefile->getCrop($suffix)->height(48)->url}?nc={$pagefile->mtime}' alt='' />"; // added a small indicator thumb to each crop-button
  10. I'm currently testing it on localhost. It doesn't load the original thumb. It loads an image that doesn't exists. Original thumb testing.-thumbnail.jpg Currently loads this non available image testing.-thumbnailn.jpg You have to modify the js code to remove the cropping values too. I'm using cropping = north. That's why the "n".
  11. Using this js fix or not when I press "Accept Crop" and the modal closes the icon-size thumb disappears. I'm getting this error on console: Failed to load resource: the server responded with a status of 404 () testing.-thumbnailn.jpg. This issue happens only after you saved the page. It should load the file as testing.-thumbnail.0x48n.jpg. The timestamp also must be used on that too in order to get always the last modified thumb and not the very first cached one.
  12. @justb3a Yep already using CroppableImage3 but it was acting weird and I was looking for alternatives but I don't think I will need them.
  13. @horst I fixed the cache problem on cropping by replacing the 145 line on ProcessCroppableImage3.module with this: 'imageUrl' => $imageUrl . "?nc=" . $img->mtime, I noticed that the Variations page is showing cached versions of my images too. I think all this is caused by Cloudflare's cache. I guess I have to find out how to disable it on the admin section of PW. EDIT: Since the images have the same url on both frontend and backend then there is no point to disable cache on backend right? The solution would be to add "?nc=" query on the Variations images too. The Variations page belongs to the core, not to your module right?
  14. Can't you see the screenshot I posted above? The modal cropping should load the non-cache version of the image with the last modified timestamp. Currently it loads the image like this which is wrong as here we get the very first cache version of the image with it's previously dimensions 1244 x 829 pixels: <div class="jcrop-holder" style="width: 1244px; height: 829px; position: relative; background-color: rgb(0, 0, 0);"> <img src="/mysite/site/assets/files/1028/mg_6550_copy.jpg" style="border: none; margin: 0px; padding: 0px; position: absolute; width: 1244px; height: 829px; top: 0px; left: -139px;"> <img src="/mysite/site/assets/files/1028/mg_6550_copy.jpg" data-width="1400" data-height="1050" alt="" style="border: none; margin: 0px; padding: 0px; position: absolute; width: 1244px; height: 829px; opacity: 0.6;"> But since I changed the dimensions from the field settings it should be loaded like this with the current image dimensions 1400 x 933 pixels: <div class="jcrop-holder" style="width: 1400px; height: 933px; position: relative; background-color: rgb(0, 0, 0);"> <img src="/mysite/site/assets/files/1028/mg_6550_copy.jpg?nc=1504572955" style="border: none; margin: 0px; padding: 0px; position: absolute; width: 1400px; height: 933px; top: 0px; left: -139px;"> <img src="/mysite/site/assets/files/1028/mg_6550_copy.jpg?nc=1504572955" data-width="1400" data-height="1050" alt="" style="border: none; margin: 0px; padding: 0px; position: absolute; width: 1400px; height: 933px; opacity: 0.6;">
  15. @horst @tpr Here is why the cropping result is always different from the area I selected: On the cropping modal it loads a cached image version where I previously had the image dimensions at 1244 x 829 pixels but currently it's 1400 x 933 pixels. If the non-cache image is loaded I bet it will fix the problem.
  16. If you mean the icon-size issue I haven't test it on repeaters. I'm just saying that if it will ever work for me it will be useful on repeaters since there is a bug there where the hover isn't triggered.
  17. The problem still exists. The icon-size is useful for me only on repeaters where the button hover image isn't displaying at all.
  18. Hi @justb3a I just found your module and I was wondering if you could add a cropping option field with all of it's values: northwest, north, northeast, west, center, east, southwest, south, southeast.
  19. The hover on button is always displaying the correct image. The problem is on the icon-size one. I do not get any js error but sometimes I'm getting this filename: test.-thumbnail.0x48.jpg while others I'm getting this: test.-thumbnail.jpg. I noticed when it's properly working it starts with this: test.-thumbnail.jpg, then with this test.-thumbnail.jpg?v=1, then with this test.-thumbnail.jpg?v=2 but If the page refreshed and crop again it starts again with test.-thumbnail.jpg, test.-thumbnail.jpg?v=1, test.-thumbnail.jpg?v=2 but without displaying the correct image.
  20. @horst On a different page (from the same site of course) I've upload the image with the original filename _MG_6550_copy.jpg and the cropping works properly. Also, the button preview will not always update. This is really messed up and tomorrow I have to give access to my client so he can start adding content. If he gets those issues I guess I will uninstall the module and use the core images field with the fixed crops.
  21. It might be a cache issue and not filename related.
  22. @horst It was the filename of the image that causing the problem. The filename was _MG_6550_copy.jpg and I changed it to test.jpg and now I can crop it properly. The button preview works too The _MG_6550_copy.jpg when uploaded it gets auto renamed to mg_6550_copy.jpg and it works fine on locahost but I don't understand why it doesn't work with that filename on the server too. What's wrong about mg_6550_copy.jpg ?????
  23. @horst I switched back to 1.1.7 and I still have the cropping problem on the server. It doesn't crop exactly the area I choose. I don't understand how is this possible to happen???? On another site on the same server with the same 1.1.7 version it crops properly.
  24. @horst @tpr The button preview never update on a production server. On localhost it's working properly. The cropping is broken on a production server. The area I choose to crop is always different on the Accept/Redo Crop screen. On localhost it's working properly. I'm using the version 1.1.10 on both localhost and the server.
×
×
  • Create New...