Jump to content

snck

Members
  • Posts

    98
  • Joined

  • Last visited

Everything posted by snck

  1. Great module, @Sebi! As it is out there for almost 2 years now, maybe someone found an elegant solution for caching the generated output (and rebuilding that cache if a page or child page is updated)? I have seen @toni´s approach and could build something on top of that for my specific use case, but I guess there are a lot of people having similar needs and would love to see something that is more ready to use. I am not experienced with ProCache, but I think being able to use ProCache to cache API output would not only be the most elegant way, but also one of the fastest possible.
  2. Hey @adrian, you are right. I was thinking of the viewBox as a set of coordinates in x/y dimension that are defining the corners of the viewbox relative to the origin of the coordinate system (this is why i called them max_x and max_y), which is obviously wrong. It should look like this: /** * Gets the image info/size of an SVG * * Returned width and height values may be integers OR percentage strings. * * #pw-internal * * @param string $filename Optional filename to check * @return array of width and height * */ protected function getImageInfoSVG($filename = '') { $width = 0; $height = 0; if(!$filename) $filename = $this->filename; $xml = @file_get_contents($filename); if($xml) { $a = @simplexml_load_string($xml)->attributes(); if((int) $a->width > 0) $width = (int) $a->width; if((int) $a->height > 0) $height = (int) $a->height; // start viewbox fix if(!$width || !$height){ if($a->viewBox != ""){ // get rid of commas: replace them with spaces $a->viewBox = str_replace(",", " ", $a->viewBox); // get rid of (now possible) double spaces: replace them with a single space $a->viewBox = str_replace(" ", " ", $a->viewBox); // get single values $viewbox = explode(" ", $a->viewBox); if(count($viewbox) === 4){ // we need 4 values, even though we are just using 2 $width = (float) $viewbox[2]; $height = (float) $viewbox[3]; } } } // end viewbox fix } if((!$width || !$height) && (extension_loaded('imagick') || class_exists('\IMagick'))) { try { $imagick = new \Imagick(); $imagick->readImage($filename); $width = $imagick->getImageWidth(); $height = $imagick->getImageHeight(); } catch(\Exception $e) { // fallback to 100% } } if($width < 1) $width = '100%'; if($height < 1) $height = '100%'; return array( 'width' => $width, 'height' => $height ); } @ryan, maybe something like this could be a useful addition to the core?
  3. @adrian Again had problems with this and got back to your idea. Thank you so much! This quick fix might be not the most beautiful/efficient way, but worked fine for me (and might also for someone else): /** * Gets the image info/size of an SVG * * Returned width and height values may be integers OR percentage strings. * * #pw-internal * * @param string $filename Optional filename to check * @return array of width and height * */ protected function getImageInfoSVG($filename = '') { $width = 0; $height = 0; if(!$filename) $filename = $this->filename; $xml = @file_get_contents($filename); if($xml) { $a = @simplexml_load_string($xml)->attributes(); if((int) $a->width > 0) $width = (int) $a->width; if((int) $a->height > 0) $height = (int) $a->height; // start viewbox fix if(!$width || !$height){ if($a->viewBox != ""){ // get rid of commas: replace them with spaces $a->viewBox = str_replace(",", " ", $a->viewBox); // get rid of (now possible) double spaces: replace them with a single space $a->viewBox = str_replace(" ", " ", $a->viewBox); // get single values $viewbox = explode(" ", $a->viewBox); if(count($viewbox) === 4){ // we need 4 values $min_x = (float) $viewbox[0]; $min_y = (float) $viewbox[1]; $max_x = (float) $viewbox[2]; $max_y = (float) $viewbox[3]; $width = $max_x - $min_x; $height = $max_y - $min_y; } } } // end viewbox fix } if((!$width || !$height) && (extension_loaded('imagick') || class_exists('\IMagick'))) { try { $imagick = new \Imagick(); $imagick->readImage($filename); $width = $imagick->getImageWidth(); $height = $imagick->getImageHeight(); } catch(\Exception $e) { // fallback to 100% } } if($width < 1) $width = '100%'; if($height < 1) $height = '100%'; return array( 'width' => $width, 'height' => $height ); }
  4. Thanks a lot for this wonderful module! It works like a charm, except for one little problem: When I use the "Accept all" button I have to reload the website for the changes to take effect. Selecting specific categories and clicking the "Save preferences" button has immediate effect. Is this an indented behaviour or am I missing something here?
  5. There is no code for it. The pages are edited in the backend by editors using the normal page edit dialogue. I do not try to store pages from one instance in the other, at least this is what I was thinking. From my understanding InputfieldPage is just storing references to pages which is what I want to achieve: Store references to pages of instance1 in a page on instance2. Maybe this clears it up?
  6. Hello, in a project I use the multi-instance feature of ProcessWire to get content from another ProcessWire instance which is kind of a "database". I do not modify the external content. For a slider I want to store references to the "database" in an InputfieldPage. To get the available pages I use the following code in my ready.php: $wire->addHookAfter('InputfieldPage::getSelectablePages', function($event) { if($event->object->hasField == 'kub_highlight_artworks') { // Server path to the PW installation $path = '/var/www/vhosts/.../'; // The root URL for the PW installation $url = 'https://.../'; // Create a new ProcessWire instance $db = new ProcessWire($path, $url); $event->return = $db->pages->find("template=artwork, sort=title"); } }); Outputting and selecting the external pages works perfectly fine, but unfortunately the selected pages do not get saved when I save the page. Can someone point me into the right direction how to make this work? Are there any internal checks whether the page exists in the current instance that prevent saving the values? Best, Flo
  7. No problem at all! Excuse me, yes, I meant the ___savedPageIndex() method. Thanks in advance!
  8. I am also really interested in this concern (and have not found an answer yet). Is it possible to have savePageIndex hooks run on a manual index rebuild? Would be awesome!
  9. Hey there, for a client website I need to implement a "reviewer" role. "Reviewers" should be able to review new (unpublished) articles to give feedback to editors, but not have the permission to change them. I built a new "reviewer" role that only has page-view permissions for the respective templates, but this permission does not include viewing unpublished pages. How can I grant them access to the unpublished articles without giving them page-edit permission? Cheers, Flo
  10. Is there any fix for this or a safe way to remove a cache field in this state without producing any harm or inconsistencies? Thanks!
  11. Strange... Could it have something to do with the fact that related_pages (in my case) takes multiple pages?
  12. Hi there, I have a problem constructing a selector that finds all pages that refer to pages with a specific template. I have pages using an event template and I want to show events based on a specific context. In this example I want to filter the results and only show event pages that relate to a specific template (exhibitions) in their page field related_pages. What I tried: $events = $pages->find("template=event, related_pages.template.name=exhibition"); Unfortunately it does not work (0 results). Same with this: $events = $pages->find("template=event, related_pages=[template.name=exhibition]"); At the moment I am helping myself with the following lines, but I have a strong feeling that there is a more efficient solution: $events = $pages->find("template=event"); foreach($events as $event){ if(!count($event->related_pages->find("template=exhibition"))){ $events->remove($event); } } I really hope that one of you can help me out. Thanks in advance! Flo
  13. Hey, I want my editors to be able to use the page lister, especially the bookmarks. I added the page-lister permission to the editor role, but Page lister ("Find" menu item) does not show. Is there anything else I have to do? Links to bookmarks work for the editors, but I would be glad to show them the menu item as well. Maybe this has something to do with the long history of the site (started with ProcessWire 2.4 and upgraded to 3.0.148 over the years)? Thanks, Flo
  14. Size alone should not be a problem (considering that I have used a lot of much bigger JPEG images with IMagick). In some cases the SVGs consisted of many 1000 paths and a lot of class definitions for their styling. I do not know the how efficient the rasterizing in IMagick works, but I guess it was the bootleneck in this specific case.
  15. Hi there, I am trying to convince a client to use image tags in a future version of the website. The plan is to have one image container per page and use tags to differentiate between different roles (header image, gallery, slider...). I thought it would be great to show also the image tags in the backend (thumbnail) overview without having to scroll through potentially long lists or clicking on every single image to see how it is output. I could not find a setting, a module or handy little hook that accomplishes this task, but maybe you have a solution? Cheers, Flo
  16. I further investigated the issue by reviewing all of the SVG files used on the pages that have thrown errors and comparing them to files from pages that were editable without problems. I realised that the guys who generated the files (architecture students) used different software in their process (Adobe Illustrator, Vectorworks etc.) which led to really complex files. I ran some of them through an online SVG minification tool which helped to resolve the issue in some cases and instructed the students to develop a kind of maximum complexity guideline for their files. To make the backend usable again and offer them a chance to exchange their "bad" files, it raised the max_execution_time temporarily in the .htaccess: php_value max_execution_time 120
  17. Yes, I mean "Locked". ? Thank you!
  18. First of all: great module! Is there any way to make it work with "locked" page fields? I have a field called linking_pages that is populated through the ConnectPageFields module for authors, tags etc. and is aiming at providing users a quick overview over relations between pages. I would love to also offer users the possibility to view or edit a page through a modal directly from the field without being able to directly interact with the linking_pages field as this field is only meant to reflect the relations but not change them directly.
  19. Dear @Robin S, thanks for your explanation! My installation was on 3.0.62 before, but maybe the fieldset has been there even longer. I am doing the access control for my fields with the "Access" tab for the specific fields as well, but I want to hide the fieldsets/tabs for users that are not able to view them (and in the future there might be a lot of them). Your snippet seems to be the perfect starting point for the desired functionality, so thanks again! Although this might be a rather specific issue, maybe fieldsets could somehow "inherit" properties from the contained fields like "if the user is not allowed to view a single field in this fieldset, he might not see the fieldset/tab as well."? This way one would keep the access logic on field level, but avoid the confusion of showing unpopulated fieldsets/tabs. Cheers, Flo
  20. Hello, for a project I have pages with different “content areas“ that can be edited only by specific user roles. In the past I setup a fieldset (tab) containing all the fields that should be available to only one specific group of users and set the fields' view and edit permissions (in the Access tab) accordingly. The result was as expected: Users assigned to the specific role could see the tab, click on it, edit content, users without the role could not see the tab. After updating this installation to 3.0.148 yesterday I wanted to setup another tab following the same principle, but I have no "Access" tab for the fieldset to limit access to the specific role. I even tried cloning an existing (and still working) fieldset. The existing fieldset has some template overrides (screenshot attached) that lead to the desired behaviour, but I am not able to reproduce these settings because there is not "Access" tab for my fieldset in template context either. Is this a bug in 3.0.148? Has the fieldset fieldtype changed? Am I missing anything here? I am glad to hear from you guys. Cheers, Flo
  21. Hi there, I am having a strange problem. I have a bunch of sites that have similar content (text, images, map markers), but I am not able to edit two specific pages in the backend. I always get the following error (or 503 service unavailable): Maximum execution time of 30 seconds exceeded (Zeile 520 in [...]/wire/core/Pageimage.php) Line 520 in Pageimage.php: $imagick->readImage($filename); All of the images used on all of the pages are SVG drawings and I have no clue why there are no problems with the majority of pages but just two of them. Maybe one of you guys has experienced a similar problem with ImageMagick and SVGs? I have debug mode enabled, but I only get these errors and nothing more specific. Is there any smart way to find the source of the error? In the assets folder for all of the pages there are only SVGs so I expect no conversion to be done. If no conversion is happening, why would the script run into the max execution time? I appreciate your thoughts on this. Cheers, Flo
  22. Thanks for your quick reply! My problem is that the client generates the PDF himself, it contains a lot of pages and gets updated regularly. Our goal is to streamline his workflow by offering him to upload just one file and having the website generate thumbnails for all pages with hi-res previews as well. I will play around with Indesign's PDF export options and try wo solve the problem by converting the fonts to paths, but we do not want to loose the ability to search in the PDF. I will try to test it on the client's server as soon as possible, maybe the configuration there magically solves my problem ?
  23. Yes, I get no umlauts in the generated image. The only font used is AvenirLT-Medium, which is embedded correctly (at least Adobe Acrobat tells me it is). The PDF hat been generated with Adobe Indesign. Left of the attached image is the output I get from the module, on the right site the PDF in Acrobat as reference.
×
×
  • Create New...