rash
Members-
Posts
112 -
Joined
-
Last visited
Everything posted by rash
-
Hi guys, I'm struggling with a PageReference inside a Combo, and the Combo is part of a Repeater Matrix. The PageReference is supposed to offer only child pages of the current page, so I use the selector string parent=page.id in the field settings. As expected, the PageReference offers all child pages (and nothing else), but saving the page throws an error for each selected child page: Page 1103 does not match findPagesSelector: parent=page.id, id=1103 Page 1106 does not match findPagesSelector: parent=page.id, id=1106 etc. Funny thing is, that the exact same construction (including Combo/Repeater Matrix) is running since years on another project, so I really don’t understand what’s going on here. Why does the PageReference offer a correct selection, but doesn’t accept the result? Supplement: For test purposes I took the Combo out of the Repeater Matrix, the problem remained the same. Next I took the PageReference out of the Combo, then everything worked. Obviously the problem is somewhere in the nested field construction. Is it possible to have a PageReference like the described one inside a Combo field and what would be its correct selector string? (And I’m still wondering why the same construction works on another site.)
-
Hi @horst, I’ve installed CroppableImage 4 additionally to 3 and everything works fine, except clicking on thumbnails in the image field. The modal window opens and says 'ProcessWire: Unrecognized path' followed by something like 'process didn’t deliver any content' (exactly: 'Der Prozess hat keinen Inhalt ausgegeben'). This happens in fields with CI3 as well as with CI4. The URL is looking good so far: /page/croppable-image-4/?filename=file-XY.jpg&suffix=square&width=420&height=420&pages_id=1781&field=imgs&modal=1. Before installing CI4 this didn't happen. PW is version 3.0.184. Edit: Meanwhile I deinstalled both versions and reinstalled V3, that is working as before now. I might wait with V4 until it’s "officially" released.
-
Most WebP images are much bigger than their JPG sources
rash replied to rash's topic in General Support
@horst Thanks very much for your detailed explanations that help me quite a lot. Following your arguments, I’m indeed comparing apples with bananas. Usually I’m working with a mixture of your strategies A & B by using one image "as is" and create further JPG variations of them, mostly thumbnails, where neither quality nor file sizes are somehow critical. As I’m planning to use WebP and a broader palette of size variations, I should probably seize the opportunity to overthink my (bad) habits and switch to pure strategy B. Embarrassingly, I never came up on the idea to use config settings for image processing, probably because I didn’t feel an urgent need for it. With strategy B they seem to be useful if not essential. So thanks for that important hint too. I will do a serious testing with all those brand new perceptions. -
Most WebP images are much bigger than their JPG sources
rash replied to rash's topic in General Support
@MoritzLost I actually don’t know which component is doing the conversion, both are running on the server. As I usually tend to go the easiest way, I just rely on PW so far: calling $img->webp->url produces a WebP. So I might dive into the deeper areas of the docs as soon as I find a little patience … The mentioned difference between the two servers results from different compression rates of JPG sources, at least that is clarified now. -
Most WebP images are much bigger than their JPG sources
rash replied to rash's topic in General Support
@MoritzLost I agree. Unfortunately, it’s the other way round until now: slighty better images with considerably larger file sizes. But I’m working on it ? I already use a picture element with different sources and want to establish responsive image sizes in the next step. And I already know your tutorial and find it pretty helpful – thanks for it! I’m not giving up yet, just had to whine a bit yesterday, because everything appeared so sadly. Regarding your settings proposal: Where could I set quality levels on a shared server with limited access to it’s settings? It‘s indeed annoying me to have either WebP or not WebP without knowing how to affect the result. -
Most WebP images are much bigger than their JPG sources
rash replied to rash's topic in General Support
@adrian Thanks for your feedback, glad to know I’m not alone. Meanwhile I did a bit more testing and found a clear correlation to the JPG compression rate. In Photoshop, a quality setting of 70 (of 100) and better leads to fairly or even much smaller WebPs, while the saving decreases with lower quality until there happens a turnaround to even bigger WebPs, approximately at 60. (The Photoshop value 70 seems to correspond to 65 in Lightroom, a bit more than 80 in Affinity Photo and something around 90 in Pixelmator Pro. The "good" JPGs on server 1 were produced by Lightroom with setting 70 and therefore match the pattern.) All things considered, the advantage of this "next-gen format" is hard to detect. To achieve a noteworthy saving in the WebPs, you have to produce unreasonably big JPGs first, but the resulting WebP will be bigger than your more realistic old-school JPG before. Measured in figures you might have better image quality, but I doubt that the difference will be recognized by the average user. So there’s a good chance that I will join your waiting-for-avif-club. -
Hi guys, I’ve recently set up 2 PW installations for using WebP images (following this explanations, strategy 3). Both servers run on identical system configurations and PW versions (3.0.184). While integrating the WebP functionality was no problem at all, I’m massively confused by the results: one server works as expected, the other one does the sheer opposite. Server 1 (the good one): Images total: 326 WebP bigger than JPG: 41 (on average more than 40 %) WebP smaller than JPG: 285 (on average 30–40 %) Server 2 (the bad one): Images total: 862 WebP bigger than JPG: 773 (on average 30–40 %) WebP smaller than JPG: 89 (on average less than 10 %) As far as I know, the quality of the source JPG has an impact on the WebP: highly compressed JPGs may lead to hardly smaller or even bigger WebPs, while the savings with high quality JPGs tend to be more spectacular. Server 1 seems to confirm this assumption (the JPGs with bigger WebPs here are highly compressed 3rd party images) while server 2 ist acting completely strange. The source JPG’s size is around 1.200 x 800 pixel with a moderate compression rate and file sizes ranging between 100 and 500 kB with an average of 250 kB. The JPG quality on server 1 is about the same (regardless the 41 lousy ones), the only difference is their smaller size of 900 x 600 px with an average file size of 150 kB. So I’d consider the WebP use on server 1 as clearly progressive, while server 2 essentially limits itself to fill up the webspace with bigger images that will never appear on a display. Is there any influence on the WebP conversion I might have missed?
-
Hi guys, I’m stuck on trying to set up a Remember Me function for frontend user logins. I’m using Login/Register to handle the logic and everything is running fine. To add the option of keeping users with a specific role persistently logged in, I’ve installed LoginPersist which does exactly what I want, as long as I use it in Automatic mode. Since it’s not always a good idea to play games in the background without letting the user know, I would prefer to let him check whether he wants to be remembered or not and use LoginPersist in Manual Mode. The doc says: I will probably be able to check the response, my problem is to get the Remember Me checkbox into the form, ideally between the password field and the submit button. The form is rendered with $loginRegister->execute(); My guess is to hook somewhere in one of the loginRegister methods, but unfortunately I can’t find a working approach.
-
Cannot login: This request was aborted because it appears to be forged
rash replied to rash's topic in General Support
Not solved, just bypassed: Fresh PW install into a different root directory on the same machine, moved old /site/ directory to the new install and set config.php to the old database and user salt. After clearing the cache and session folder, everything runs fine now. Fortunately, this very obscure situation appeared on a site that is managed by myself and nobody else. To have this on customer work would probably be a nightmare. I don’t know if it’s possible or rather a security issue, but I would appreciate it very much if an error message would reveal a bit more than 'This request was aborted because it appears to be forged'. The error seems to occur repeatedly at least since 2012 without any systematic debugging strategy beyond guesswork into the blue. To hear that something went wrong is arguably better than complete silence, but a bit more information what the system doesn’t like would be helpful. -
Cannot login: This request was aborted because it appears to be forged
rash replied to rash's topic in General Support
@Pixrael Thanks for your help. Your thread is one of those I read before, but it didn’t lead me much further. It seems as if the error can have approximately thousand different causes and so the 127+ forum topics you mentioned are mostly guesswork with some enviably happy winners. That’s not meant sneeringly, I know that server based issues can be very hard to catch. In my case I’m not sure whether I’m struggling with a server case at all. When you go to bed with a working site and wake up the next morning with an unworking one without any changes on your system, it’s not very likely that your database acts suddenly strange or your PHP session path is not writable anymore. Furthermore I copied the site to a local environment in the meantime, where precisely the same shit happens. As far as I can see, it has to be something inside the /site/ directory or the database. As I updated to the latest dev version, /wire/, index.php and htaccess should be fine. -
Replace the original image with a resized variation of itself.
rash replied to Zeka's topic in General Support
As far as I understand it right what you want to achieve, I would loop through all pages with an API script, delete the old image(s) of each, put the new image(s) to the same field and save the page. I have a similar situation on a site where a lot of images get synced with external sources very often and the delete & save method works reliable. -
Hi all, on a site working flawlessly since a few years, I suddenly cannot login anymore, all I get is 'This request was aborted because it appears to be forged'. The site runs on a shared hosting server, my last active changes happened many months ago and the hosting service usually changes nothing without clearly notifying it long before. Means: I haven’t got the slightest clue where to start. Of course I’ve used the forum search, read probably all related threads and followed the most hints (some of them are pretty old, so I decided to be cautious) but no success. A few facts: - I don’t know the exact PW version as I can’t find it outside the unaccessible backend, but it should be at least 3.0.16X. - TracyDebugger is in use on this site, but not SessionHandlerDB. - I deleted /site/assets/logs, /site/assets/cache and /site/assets/session. Before I did that, all of them were writable. - I replaced index.php with the latest dev version. - When I set $config->protectCSRF to false, the message disappears, but the login page gets constantly reloaded. - Setting $config->debug to true delivers 'Deprecated: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior in .../site/config.php on line 104', followed by warnings, that the header was already sent by.
-
[Solved] Admin search in custom fields not working as expected
rash replied to rash's topic in General Support
@BillH Meanwhile the hook is working. All data is collected in one textarea that I’ve set to hidden. It still is a workaround in the sense of not going the direct way, but it does what I wanted to achieve without any noise or bad smell, so I would call it an excellent solution. Means: my efforts on searching for something different declined dramatically. Here is the complete hook – less for you as the "inventor", but for others that may get stuck at the same point. I keep the code in /site/templates/admin.php as it is admin related only, but /site/ready.php would work as well. <?php $wire->addHookAfter("Pages::saveReady", function($event) { $page = $event->arguments(0); $page->of(FALSE); // disable page formatting $cache = ""; // string collecting the single fragments if ($page->template == "invoice" || $page->template == "standard") { // blocks is a Repeater Matrix field with the types item and text foreach($page->blocks as $block) { if ($block->type == "item") { $cache .= $block->title." "; $cache .= $block->body." "; } else if ($block->type == "text") { $cache .= $block->body." "; } } // notes is a direct child of $page $cache .= $page->notes." "; } else if ($page->template == "customer") { // cust_base is of (pro) field type Combo, it stores data different // from Repeater Matrix fields but shares a similar syntax $cache .= $page->cust_base->street." "; $cache .= $page->cust_base->city." "; $cache .= $page->cust_base->shorthand." "; $cache .= $page->cust_base->phone." "; $cache .= $page->cust_base->email." "; $cache .= $page->notes." "; } else if ($page->template == "contact") { // cust_contact is a Combo field too $cache .= $page->cust_contact->prename." "; $cache .= $page->cust_contact->surname." "; $cache .= $page->cust_contact->phone." "; $cache .= $page->cust_contact->email." "; $cache .= $page->notes." "; } // searchcache is a simple Textarea field that can be included // as a searchable source in Modules/Core/ProcessPageSearch $page->searchcache = $cache; }); ?> -
Trying to create progress bars for Processwire generated cards.
rash replied to spercy16's topic in General Support
I am happy too! Though I don't understand why the typecasting didn’t work, (int) "40000" (or intval("40000")) should result in 40000, not 0. Strange …- 13 replies
-
- conditional statement
- typecasting
-
(and 4 more)
Tagged with:
-
The most simple way to achieve that is to call a detail page (based on a detail template) and specify the news item with a get parameter like so: <p><a href="/newsdetail/?newsid=<?= $item->id; ?>">read more</a></p> In this case, your detail template would contain only the logic to receive an id and render the markup for $item with the given id. If you don’t like get parameters, you could alternatively use form submits instead of <a href> and send the ids as post variables.
-
Trying to create progress bars for Processwire generated cards.
rash replied to spercy16's topic in General Support
You still didn’t reveal your results. Could you do something like that to see the four values and their according types? $raised = $page->get("raisedAmount$count"); $goal = $page->get("goalAmount$count"); $goalNum = (int) $goal; $raisedNum = (int) $raised; echo $raised; echo gettype($raised); echo $goal; echo gettype($goal); echo $goalNum; echo gettype($goalNum); echo $raisedNum; echo gettype($raisedNum); Normally it shouldn't be much of a problem to divide two integers in PHP, so I suspect it to be slightly more hidden.- 13 replies
-
- conditional statement
- typecasting
-
(and 4 more)
Tagged with:
-
Trying to create progress bars for Processwire generated cards.
rash replied to spercy16's topic in General Support
Ah, okay, I see. It was a bit confusing without knowing the context. But what values/types exactly do you get after typecasting $goal and $raised? Did you try intval($val) instead of (int) $val?- 13 replies
-
- conditional statement
- typecasting
-
(and 4 more)
Tagged with:
-
Trying to create progress bars for Processwire generated cards.
rash replied to spercy16's topic in General Support
What are raisedAmount$count and goalAmount$count you’re getting with $page->get? Fields that contain a dollar sign? Or is $count supposed to be a subfield of raisedAmount/goalAmount ? I’ve never seen a construction like that with dollar signs in, usually you do $page->field or $page->get('field') and field names cannot contain dollar signs, as far as I know. So what are the results of those two get calls if any and what are their types when you ask for gettype($goal) or gettype($goalNum)?- 13 replies
-
- conditional statement
- typecasting
-
(and 4 more)
Tagged with:
-
[Solved] Admin search in custom fields not working as expected
rash replied to rash's topic in General Support
I agree with your problem assessment and know the repeater.field construction from several front end searches/selectors. It’s probably a limit of dragging and dropping fields instead of setting up selectors manually. As fields inside a repeater stay ordinary fields with sort of a virtual framework around them, the field select lists only the basic fields without any knowledge of their repeater context. (If I remember it correctly, there is a similar limitation at FormBuilder’s drag & drop field mapping.) Your first solution proposal sounds very interesting, though I’ve never even recognized the existence of the field type Cache before. So I did what you suggested and got pretty excited, but only until I tried to include my astonishing new Cache field to the search list: it’s not offered as an option. Obviously the select is restricted to text and textarea fields with no exception. As long as I don’t find anything better, I will solve it with your proposal #2. It might not be the most elegant thing on earth, but definitely a sturdy workaround and therefore a very good idea. Thanks a lot for it! -
[Solved] Admin search in custom fields not working as expected
rash replied to rash's topic in General Support
Thanks for yor reply @BillH, while it didn’t help me in a direct way, it did so indirectly. If A works on B but not on C, it’s a good idea to investigate the differences between B and C. Although I don't know your environment, I found one thing I suspected to be possibly specific and this first trial already brought the little devil on stage: all included fields reside in Repeater Matrix fields. As soon as I take them out and keep them as fields of the page itself, everything is running smooth. So I redefine my question: Is it possible to include text or textarea fields of Repeater Matrix fields into the admin search scope? (I guess the problem will be the same with simple Repeater fields.) -
Hi guys, I tried to customize the admin search by adding more fields to be searched, following this older thread. Modules/Core/ProcessPageSearch promised to be an easy thing, as you just select the (text/textarea) fields you want to include. Sadly, content in this additional fields doesn’t get found at all. I cleaned the module cache, saved a few test pages etc. but there’s nothing found beside text in the title field. Am I missing something?
-
[Solved] Lock page with hook after/before Pages::saved?
rash replied to rash's topic in General Support
Yes, it does for me here too. Started to work immediately after I eliminated a typing error in my template name. (In fact I didn’t assume one second you would post non-working code, but was pretty sure the problem is located in front of my display.) So another big thanks, that was very instructive. -
[Solved] Lock page with hook after/before Pages::saved?
rash replied to rash's topic in General Support
Thanks a lot for you help, @Robin S – at least your first proposal ist working, while the alternative with Pages::saveReady doesn’t. Actually the loop problem is quite obvious, so shame on me for not detecting it myself, my brain sometimes seems to be somehow blocked. Anyway, just to consolidate the new enlightening: when I do $page->setAndSave("field", $value) before Pages::saved everything is fine. That’s because I’m saving field values whereas locking a page saves no field value but the page itself and therefore causes the loop. Is that correct? Nevertheless would it be interesting to understand why your alternative isn’t working. -
Hi all, I’m trying to lock a page before or after save if a field has one of two specific values. Sounds easy, but keeps me busy since hours. My hook: $wire->addHookAfter("Pages::saved", function($event) { $page = $event->arguments(0); if ($page->template == "invoice") { $page->of(FALSE); // lock page if inv_status = paid (1034) or cancelled (1038) if ($page->inv_status == 1034 || $page->inv_status == 1038) { $page->setAndSave("status", "locked"); // result: page gets locked, but I receive 'Service Unavailable' // I also tried this with the same result // $page->addStatus("locked"); // $page->save(); } } }); The page gets locked but I receive this notorious 'Service Unavailable' message that starts to bore me a bit. Tried several other variants with identical results, the same goes for firing the hook before instead of after. Maybe it’s illogical to lock a page and save this status change immediately after, but when I don’t save the change, of course nothing at all happens.
-
[Solved] Reconstruct PW site when server data is lost?
rash replied to rash's topic in Getting Started
Hi @netcarver, the combination of installation salt and password reset finally let me log in. The rest is easy though annoying work, but stupidity needs at least mild punishment. Thanks a lot for your help!