-
Posts
1,317 -
Joined
-
Last visited
-
Days Won
60
Everything posted by BitPoet
-
Big thumbs up for that idea. If the timing is right, I might even make it to both, since I'm planning to head across the pond and hike the John Muir Trail next summer. Love the preload method. I've got a shop solution built on PW with about 120k orders and 150k order positions by now, all as pages. Performance is becoming a bit of an issue in the backend with long range price change statistics and detailed Excel exports, and this seems like a perfect use case.
-
Error handling when using WireDatabasePDO?
BitPoet replied to AAD Web Team's topic in API & Templates
WireDatabasePDO's constructur doesn't connect to the database yet. This is either implicitly done when the query or exec(ute) methods are called, or explicitly by invoking $db->pdo(), which will return the underlying plain PDO object. -
Yes, I did. Sorry for the mixup. If upping wait_timeout, deleting individual entries from your image field's table is normally an option, but I'm not familiar with ImageExtra. So I'd make sure to have a working database backup before attempting it. One thing you could try is setting the field you want to exclude from saving to hidden.
-
Is that on a shared hosting server? The error indicates that the execution time of a mysql query was exceeded or a memory limitation in the database was reached, in which case the server aborts the query and drops the connection. Those are often pretty close knit on shared hosts. If you have access to the database itself, the first thing to look at would be wait_timeout. "SELECT @@wait_timeout" will give you the seconds MySQL will spend on a query. If that is very low, you can try setting a higher per-session value through $config->dbInitCommand in site/ready.php. $config->dbInitCommand = "SET NAMES '{charset}'; SET wait_timeout = 300";
-
How would you opt to do a date field with optional DD/MM?
BitPoet replied to cst989's topic in General Support
The question prompted me to put FieldtypeSketchyDate on GitHub. It's a small module I started writing for a solution that never went anywhere, so its pretty basic. It may be a starting point though. In short, it lets you enter 2024 or 2024/10 or 2024/10/11 in the date value, and it also lets you search for 2024/10 and returns all pages with a date between 2024/10/01 and 2024/10/31 as well as those where 2024/10 was entered. So far, it just validates the formatting through the HTML pattern attribute. Proper date validation and calendar UI are still on the todo list. -
[SOLVED] How to save fields on a Process page of a module?
BitPoet replied to PWaddict's topic in General Support
As an alternative, but which also involves some coding: you can also create fields + fieldgroup + template + a "storage" page in your module's install method. Then, in your processForm method, you can fetch that page and assign the form values there, or you just display a modal link to the page editor in your buildForm method and let PW take care of saving the values. That approach can get a bit involved (double so if you want to clean up in your uninstall method), but it can have some advantages (retaining the values after module uninstall, straight forward use of arbitrary field types). -
Consistent errors during installation - does anyone else get these?
BitPoet replied to BrendonKoz's topic in General Support
The first thing I'd look for would be whether there's an auto_prepend_file entry in php.ini. -
The interesting information is probably in the response body for the call to edit/?id=????%InputfieldFileAjax=1.
-
I bet you didn't forget to assign a sensible page name, then ?
-
It should be faster with transaction, and I did add startTransaction and commit in my import script. I'm still trying to figure out where the bottleneck is. Shouldn't be the hardware (i9-14900K, 64GB, high speed NVMe SSD), and I didn't see any io waits in the stats, so something is probably wrong with my db server (MySQL 8.4.0 on Windows 11). Looks like I've got do some forensics there.
-
Yep. About 24 hours on InnoDB for a full import. More that 52k books, 983 genres, 48k characters, 10k publishers, 15k awards. All in all 95314 pages in an otherwise pristine PW installation. I'm attaching a site profile with the data if someone wants to play around. site-bookinventorydata.zip
-
Just a thought for future in case performance really becomes an issue for someone: it's possible to add a generated + stored column to a MySQL table that feeds itself from a dedicated value in a JSON column, and this column can of course have a fulltext index. A hook on PageFinder::getQueryUnknownField could then "redirect" the query to the generated column. Would only work on single valued fields, of course. For anybody interested in creating such a generated field from a JSON field, here's a blog entry that explains it better than I could.
-
You should be able to append the required settings to $config->dbInitCommand.
-
session variable randomly not set in multi instance context
BitPoet replied to elabx's topic in General Support
Did you set $config->sessionName to different values? -
I'd probably approach that with a hook on User::unpublished, perform the checks there whether the user is staff and referenced from a client account, and send a message (through PW's message system or even other means like a ticket system or email).
-
In AdminDevModeColors, I hook onto AdminTheme::getExtraMarkup, but that's probably not much different from your approach.
-
It seems that I'll have to rename the module if I really decide to pursue developing it (which I doubt more and more). rtf.js unfortunately can't deal with the different dialects of RTF. I've removed the dependency and hacked together a pretty dirty regular expression that extracts image data from the RTF clipboard contents, then looks for img tags in the HTML contents and replaces the src for every found image with the extracted images in the same order. Whether that is practicable outside of my simple test cases is up for discussion. So far, the images always came in the same order in both formats. I'm currently only extracting PNG and JPG and insert a placeholder for others. I'm beginning to understand why TinyMCE's PowerPaste plugin is commercial.
-
Since it came up in this question and I had some time to kill in front of my computer waiting for updates to finish which I had to verify, I got curios whether copy & paste from Word on Windows into a TinyMCE editor field could be made to insert the formatted text and keep the images. Surprisingly, with the help of rtf.js, this went pretty quickly. Ryan already built automatic upload functionality (called ImgUpload) into the TinyMCE field, so I only had to enable the option and select a target field. Even though pasting word processor generated HTML is and always has been a sin, I built a small module for it anyway. I called it (I know, it sounds a bit clunky, but it was the best I could come up with, I'm a backend guy): RtfPasterTinyMce Usage Download the contents of this repository and unpack into a folder in site/modules Open ProcessWre admin and select Modules -> Refresh Click "Install" for "Rtf Paster TinyMCE" Go to "Fields" and select your TinyMCE field where you want to paste office content including images Check "rtfpaster" in "Additional plugins" on the "Input" tab and save your field configuration Edit a page with that field and copy a passage that contains both text and images from MS Word into your TinyMCE field. You should see your images there. Advanced Go into InputfieldTinyMCE's module settings and enable "Image fields for ImgUpload" Edit your TinyMCE field and select an existing image field in the "Image fiels for ImgUpload" select on the Input tab Paste some text / images mixture from your word processor MS Word Tadaa! Your images are magically uploaded into the selected field. Since the RTF doesn't contain any information about the file name of the source image, your uploaded images will be named fieldname.png, fieldname-1.png, fieldname-2.png etc. Keep in mind that this is so far a proof-of-concept module and hasn't been tested with different scenarios and source applications yet. Don't use it in production unless you feel confident to fix any errors yourself! Edit: Only successfully tested with MS Word. Not working with LibreOffice's RTF.
-
I just played around and enabled the "Image fields for ImgUploads" in InputfieldTinyMCE's module settings. Then I selected an existing image field in the identically named select in my TinyMCE field's Input settings. Pasted from Word to my field and the image got uploaded without any further changes on my part!
-
Out of curiosity, I've created a small proof-of-concept module/plugin for InputfieldTinyMCE. If activated, it tries to fetch RTF clipboard content, parse that to HTML (with images as data: URLs) and insert the result, overriding TinyMCEs default paste behavior. I only did a small test so far. Maybe you'd like to do a test drive. https://github.com/BitPoet/RtfPasterTinyMce It uses https://github.com/tbluemel/rtf.js for the heavy lifting. Edit: forgot to say: this could of course be expanded to extract the image data, upload that to a dedicated image field through PW's standard upload endpoint and use the URL of the uploaded image in the inserted HTML.
-
Pasting from office applications is a complicated topic. The Windows clipboard can offer different formats of its contents to applications you paste to, e.g. plain text, HTML or image data, or different other data formats both the application you copy from and the receiving application have registered with the Windows system. In the case of copying from Word, your clipboard will look similar to this: The paste handler in the receiving application needs to be able to parse one of the provided formats. You'd think there's HTML in that list, so TinyMCE could simply paste that and all should be well - well, there's a caveat. Office tries to be nifty and conserve memory, so the HTML in the clipboard contains links to local files, which look like this in the source: <img width=224 height=237 src="file:///C:/Users/Someone/AppData/Local/Temp/msohtmlclip1/01/clip_image002.png" v:shapes="Grafik_x0020_1"> Into the game come security zones and same origin policy, and so no, file:///somewhere isn't going to make it into your inline editor. Safari on MacOS is a different kind of beast. The pasted HTML contains the images inlined as blob URIs, something similar but not completely interchangeable with data URIs. There's a plugin for TinyMCE that promises to be able to paste the full HTML with the images and even call an upload handler with the image data. No idea if that one parses the RTF version of the clipboard instead or does some other magic. But, OTOH, I really wouldn't want my users to paste formatted content from office apps. Been there, seen the disaster, and never want to go back there. It never plays well with surrounding HTML, it tends produce awful glitches when scaling things and in the end, the frustration on the users' side always far outweighs the initial convenience. In case you're curious about the things available in your Windows system's clipboard, you can take a peek with InsideClipboard (that's how I took the screenshot above).
-
[SOLVED] LazyCron possible on every page load, or other technique?
BitPoet replied to nurkka's topic in General Support
Did you try hooking after ProcessPageView::finished? That's what LazyCron does. You may want to add a check for regular page views like LazyCron does here. -
How to allow system templates for InputfieldSelector for a field?
BitPoet replied to artfulrobot's topic in General Support
That shouldn't be a problem, actually. The WireHook class (someone correct me if I'm wrong) just builds a Selector and stores that in its hooks array. Every time a hookable method is called (through PHP's magic __call method), WireHook::runHooks is executed and checks wheter the any of the stored selectors match the currently called class and method and execute those. So it shouldn't matter when exactly you add the hook as long as PW's core has been loaded. For me, it's just a question of keeping the system startup lean why I perfer to add hooks in ready instead of init unless they have to be executed before ready() is triggered. In theory, it shouldn't matter, but I haven't delved too deeply into the issue.