-
Posts
11 -
Joined
-
Last visited
-
Days Won
1
Posts posted by thuijzer
-
-
30 minutes ago, Soma said:
Just doing this in my basic-page template works fine:
$page->of(false); foreach($page->images as $img) { $img->focus("10%", "10%"); } $page->save(); $page->of(true);
Yes. This is indeed how I thought it should work.
I just discovered that it only works when I create a new image.
For example:
// this works: $member->of(false); $member->avatar = $filename; // avatar becomes a \ProcessWire\PageImages $member->avatar->first->focus(10, 10); $member->save(); $member->of(true); // this does not work: $member->of(false); $member->avatar->first->focus(50, 50); // avatar already is a \ProcessWire\PageImages $member->save(); $member->of(true);
By the way: $member is a \ProcessWire\User but I don't think this should be the problem.
So I guess I'm doing something else wrong.
Thank you for your reply!
-
First I like to say that the new(ish) focus function for images is really great!
But I can't seem to save focus via the API. Does anyone know how to do this?
I tried all methods described in Pageimage.php:
$member->avatar->focus($top, $left); $member->save();
$member->avatar->focus($top . ' ' . $left); $member->save();
$member->avatar->focus([$top, $left]); $member->save();
But whatever I try, the focus is never updated/saved.
Extra note: in de database the field "filedata" becomes empty when I use the methods described above.
-
5 hours ago, Juergen said:
Most of the time I use this library for business hours. You can take a look at it: https://github.com/spatie/opening-hours
This will take care of exceptions (like public holidays)
I've never seen that library. That is looking very good. Maybe I will just use this library and create a fieldtype that creates the right settings for this lib. Looks like the license makes this possible.
Edit: looks like it needs PHP 7. I think a lot of ProcessWire users are still on 5.6 or even lower, so maybe that's not an option.
But I can always take a look at the source -
17 minutes ago, Juergen said:
Hello @thuijzer,
I dont know if others agree with me, but I would find it useful if an extra input field for public holidays will be added after Sunday. Fe in the gastronomy there is often the scenario that the business is open on public holidays. Here in Austria most of the time restaurants are closed on Monday, but if it falls on a public holiday they are open. So an extra field will take care of this. If the field will be left blank business is closed on a public holiday.
Best regards
That sounds like a great idea. I will think about a way to enter dates that override opening hours.
- 1
-
On 19-1-2018 at 8:57 PM, Juergen said:
Hello thuijzer, I always get this error message after calling
echo $page->field_name[1]->entries[0]->getFrom()->format('H:i');
in template:
Cannot access private property ProcessWire\BusinessHoursDay::$entries
Best regards
My bad. The documentation is wrong.
I like to use immutable objects so I created a getter function for the enries: getEntries()
The readme is now updated.
- 1
- 1
-
@louisstephens Thank you for the screenshot! Note that a 24 hour input is used. So on Saturday you will be open from 3:00-6:00AM and 10:30-12:00AM.
-
https://github.com/thuijzer/processwire-FieldtypeBusinessHours
Fieldtype Business Hours
ProcessWire Fieldtype for entering business hours (opening hours)
Input format
Leave a day empty when closed on that day
Times are in 24 hour format.
9:00-12:00 9:00-12:00, 13:00-17:30 16:00-2:00
Usage in templates
Days are from 1 to 7 where 1 is Monday and 7 is Sunday (ISO-8601)
echo $page->field_name->isNowOpen() ? 'Now open' : 'Now closed'; if($page->field_name[1] == null) { echo 'Closed on Monday'; } if($page->field_name[2]->inRange('11:00')) { echo 'Tuesday at 11:00 open'; } echo $page->field_name[1]; echo $page->field_name[1]->getEntries()->getFrom()->format('H:i');
- 14
- 2
-
Good find! ..., and welcome to the forums.
Thnx
I'm totally new to ProcessWire and already starting to become a fan
Thank you for the introduction to PIA
- 2
-
While reading the code I noticed the suffix options in the Pageimage class.
It seems some settings are added as suffix but not all. So my workaround for now is:
$url1 = $image->size(100, 100)->url; $url2 = $image->size(100, 100, array('upscale' => false, 'cropping' => false, 'suffix' => array('noupscsale', 'nocrop')))->url;
Resulting in:
- image.100x100.jpg
- image.100x100-noupscale-nocrop.jpg
- 2
-
Right now this doesn't seem to work:
$url1 = $image->size(100, 100)->url; $url2 = $image->size(100, 100, array('upscale' => false, 'cropping' => false))->url;
This is because a filename like image.100x100.jpg is created for both settings.
Is there a workaround for this?
If not, maybe an additional MD5 hash of the settings could be added to the filename: image.100x100.d8e8fca2dc0f896fd7cb4cb0031ba249.jpg ?
- 1
Save image focus
in API & Templates
Posted
Yes I made sure I'm working with a Pageimage, but I still don't get it.
What I see:
So somewhere along the way the "changes" property is reset for the avatar field, but I can't figure out when and why.
Going to dive deeper into this ?