Leaderboard
Popular Content
Showing content with the highest reputation on 01/13/2024 in all areas
-
This week on the dev branch are some fixes and improvements, but we'll likely wait another week before bumping the version number up. Some new hooks have been added to $pages, including moveReady(), restoreReady() and renameReady(), to accompany the existing moved(), restored() and renamed() hooks. There was also some refactoring with the way that some hooks are called from $pages to improve their reliability and cover some edge cases where they might have not been called before. See the dev branch commit log for more. The biggest addition this week is likely the newly added support for custom page classes for repeater items. This was added to respond to a feature request initiated by @thetuningspoon and @Jonathan Lahijani let me know about earlier in the week. Here's how it works. If you have a repeater field named "menu_items" then you could create a class named MenuItemsRepeaterPage in /site/classes/MenuItemsRepeaterPage.php, and it would use your custom class rather than the regular RepeaterPage. Though note it must extend RepeaterPage. <?php namespace ProcessWire; class MenuItemsRepeaterPage extends RepeaterPage { // ... } This works with RepeaterMatrix and FieldsetPage as well, since both are derived from regular repeaters. But since both have their own Page classes you'd want to extend their page classes rather than RepeaterPage. In the case of RepeaterMatrix, it uses a class called RepeaterMatrixPage. So if your Matrix field is named "hello_world" then you'd create /site/classes/HelloWorldRepeaterMatrixPage.php: <?php namespace ProcessWire; class HelloWorldRepeaterMatrixPage extends RepeaterMatrixPage {} If you want a custom class for your FieldsetPage field named "seo" then you could create /site/classes/SeoFieldsetPage.php: <?php namespace ProcessWire; class SeoFieldsetPage extends FieldsetPage {} Let's say that you want to use a custom class without using the naming convention and/or file(s) above. You can tell the fieldtype what class to use for its item(s) like this: inclue_once('/path/to/MyCustomRepeaterPageClass.php'); $field = $fields->get('your_repeater_field'); $field->type->setCustomPageClass($field, 'MyCustomRepeaterPageClass'); In the example above, MyCustomRepeaterPageClass would extend RepeaterPage. You'd probably want to do this during the "init" or "ready" state, or at least sometime before you load any items from your Repeater (or Matrix or FieldsetPage) field. If your custom class is not in the ProcessWire namespace, then you'd want to include the namespace in your call, i.e. setCustomPageClass($field, "\\MyNamespace\\MyCustomClass"); If your custom page class is already in /site/classes/, or some other path where it can be autoloaded, then the include_once() line isn't necessary. (API ref pages for getCustomPageClass and setCustomPageClass). Big thanks this week to typneun Designagentur (https://typneun.de/) for posting more than 20 awesome new sites to our ProcessWire sites directory! That made my day. Thanks for reading, more next week, and have a great weekend!5 points
-
Hi @ryan, Thanks for this update. One easy to overlook but important missing part of the repeater update that was made is what happens if you edit a repeater item directly. Assume we have a repeater field named 'books' and you edit the repeater item page by going to /admin/repeaters/books/(for-page)/repeater-item-page When editing it directly, the page to be edited simply gets the RepeaterPage class instead of BooksRepeaterPage class. I managed to hack-fix this by doing this in /wire/core/Templates.php: // determine if custom class available (3.0.152+) if($usePageClasses) { // generate a CamelCase name + 'Page' from template name, i.e. 'blog-post' => 'BlogPostPage' $className = ucwords(str_replace(array('-', '_', '.'), ' ', $template->name)); // *** *** hack fix: if we are editing a page with a template that starts with 'repeater_', assign the correct page class! *** *** if(str_starts_with($template->name, 'repeater_')) { $className = __NAMESPACE__ . "\\" . str_replace(' ', '', $className) . 'RepeaterPage'; $className = str_replace('ProcessWire\Repeater', 'ProcessWire\\', $className); } else { $className = __NAMESPACE__ . "\\" . str_replace(' ', '', $className) . 'Page'; } if(class_exists($className) && wireInstanceOf($className, $corePageClass)) { $pageClass = $className; } } Can what I described be supported as well?3 points
-
Good to hear @bernhard, that you like Cursor so far. Over the course of the last year, with all that AI hype going on, I have tried several AI assistants integrated into VsCode through extensions. Copilot, Codeium, Cody, Tabby, to name the major ones. Now about 10 days ago I stumbled across Cursor and have worked with it since. Guess, I'm a bit late to the party, seeing how well it is anticipated in the Dev community. Cursor is integrating AI, more specifically OpenAIs GPTs, exceptionally well into the IDE. It is available when you need it, but doesn't get into your way. The UX is extremely good, in my opinion. What makes it really stand out from other solution, is the ability to build indices of your code base and give them as meaningful context to the AI. While other tools can also do this, the process of indexing and referencing the index is very efficient in Cursor. This is great for onboarding to new code bases. Cursor indexes the code and you can ask questions and, in most cases, it will be spot on with it's answers. So you very quickly find your way to the relevant parts of the code for the task at hand. The killer feature that I like the most and that I have not seen in any of the other tools is called Docs. With a simple command '@Docs' you point Cursor to a URL, let's say https://processwire.com/blog/posts/pw-3.0.173/ (URL Hooks documentation) and it will create a vector based index of those docs in the background. You give these docs a custom name, pwUrlHooks. Now you can reference them inside your instructions to the assistant with @pwUrlHooks. This drastically reduces hallucinations and produces very good code suggestions in most cases. I's really fun to watch the AI writing code for you that you can actually use. Cursor itself is free. But you only get like 50 requests a month for free. If you need more, they ask 20$/month. But you can also use your OpenAI API key to have unlimited requests. Then you pay OpenAI, of course. But at least you have the choice. And 20 bucks a month isn't that much after all for the time that this can save you. I'm not affiliated with them in any way. Just find it a pleasure to work with. EDIT: Here's a link to the docs. I couldn't find that on the Cursor website but they seem to be the official docs: https://anysphere.mintlify.app/get-started/moving-from-vsc-to-cursor2 points
-
@FireWire At first glance, this looks great. I'll pull that dev branch version down and test it out as soon as I can. Thanks! Hopefully someone here has a good idea for the second issue. [fingers crossed]2 points
-
Yesterday I had a chat with @gebeer and he showed me Cursor - The AI First Code Editor. It's based on VSCode, so if you are working with VSCode it will be a very similar experience. It can help you writing docs: It can help you refactoring code: And it can help you writing newsletters (testing that it understands the contest of the file for the prompt): I'm sure it can do much more great stuff. @gebeer mentioned a @docs feature - maybe you want to explain that? ? You can either access the AI with your own OpenAI API key or you can use their free tier or buy a subscription starting from 20$ per month. I'm testing it but so far it looks like a good companion. What it did not do for me is to translate all JSON files in the /de folder to spanish translations in the /es folder. It told me it can't do that directly but gave me a python snippet how I can achieve this. I'm in contact with @FireWire about that ? Have a good weekend! Ah, and if you are not subscribed to Rock Monthly here is the link: https://baumrock.com/rock-monthly/ ?1 point
-
Hi, so far worked with Copilot and VSCode. As I have an OpenAI API key as well, I will try out Cursor this weekend. Thanks for sharing the info.1 point
-
1 point
-
JetBrains also added to PhpStorm (and other products) an AI assistant based on ChatGPT, I didn't try it yet.1 point
-
Welp, that second one is a weird one... I went out of my way to try and make sure that was handled- it works on the TinyMCE and CKEditor fields, didn't notice the other fields were affected. I'll have to chew on that for a minute since it's a relationship between JS and the browser's acknowledgement that something has changed. Searching for that specific info is harder than I thought it would be. If anyone has any info they'd like to throw out there on this, would surely appreciate it. I misread this entirely and my code was at fault. Information on fix in reply below. As for the first request, how about this? Config page now has the option to choose "Both" for the translation action. Second button only shows up on non-default language tabs. Download it on the Dev branch and let me know if that works for you!1 point
-
Fluency has been added to the ProcessWire modules directory! https://processwire.com/modules/fluency/ The readme and module documentation has been expanded significantly to document all of the features available to you when using Fluency, including markup rendering. Enjoy!1 point
-
Got tagged by @monollonom over in this Weekly Update post. Dropped a new Fluency feature. One click translation for any module, core or otherwise. I translated all user-facing strings for Fluency itself to Slovak in 4 seconds. This may be useful for developers who need to get modules that end users will interact with in the admin localized much much faster. This uses a feature in Fluency where you can bulk translate a large group of texts to from one language to another at the same time. Just for kicks I translated the entire ProcessWire core in under 30 minutes- that includes modules I don't even use. It would certainly need some proofreading, but the amount of work up front is significantly reduced. Available on the dev branch.1 point
-
Yeah that makes sense. I was more curious if you simply installed Yootheme Pro to a directory and referred to different style chunks (like if it is templated out in partials or whatnot). I haven't trialed it or anything to see what the file layout is like. In the past the tm-classes they add were sometimes useful helpers that added to the core uk-classes - although they have gotten better about bringing the 'helpful extras' into uikit core. WP has its moments, but I find that a lot of the extra power user think they need ends up biting them in the end because of the extra work it creates for them and PW has better ways of narrowing user focus to the essentials they need to do. So you add all these plugins that folks want and now suddenly they are frustrated with the weight of the sword they weild.1 point