-
Posts
291 -
Joined
-
Last visited
-
Days Won
2
Everything posted by Pierre-Luc
-
That’s pretty neat teppo! The feature will be implemented a bit further down the road on this project so it’s far from too late! I’ll let you know when I’ll start playing with it. Awesome, thanks again!
-
Pushover looks pretty cool. I’m currently implementing realtime functions in a PW project using http://pusher.com, totally recommend it!
-
Version 0.9.5 - Adds language fields support I just pushed version 0.9.5 to master. This version adds support for multilingual fields. I made a few tests but let me know if you stumble on something weird.
-
Depending on how your server image is setup the locale might not be activated which means it won’t output translated vales. You can check what locales are installed on your (assuming this is a linux variant) terminal : locale -a Do a quick google search to find the appropriate command to enable a locale on your system.
-
Hi teppo, is there a way to get the changes from the api? $page->currentVersion->typicalFunctions; $page->previousVersion->typicalFunctions; I’m looking at implementing a status notification system for a project and this would be handy. For this I would need to grab different fields or a specific one and check for differences using a hook.
-
Super Smartypants is a ProcessWire textformatter module which adds support for languages. It also allows you to set the different Smartypants Typographer parser attributes to customize which rules apply and fixes some bugs. Super Smartypants requires the language module. Usage After installation, add /site/modules/TextformatterSuperSmartypants/smartypants.php to your language translations. To enable Super Smartypants for a language, set the Smartypants attributes field to 1 (or see below for details), otherwise to disable leave the field empty. Change default strings according to your masterful typographic knowledge. Documentation and download : https://github.com/plauclair/SuperSmartypants
- 15 replies
-
- 11
-
Thanks! You’re right apeisa, think it would be better to rename it?
-
I moved the topic to https://processwire.com/talk/topic/6727-field-generator/. This was initially only a question about how do I approach this, it’s useless now.
-
Field Generator is a module to help you create random character strings and automatically assign them to one or multiple fields of your choice when a page is created. When setup, it will automatically do so whether you create a page through the administration panel or through code, meaning you don’t need to set $page->name or any other field of your choice, it just works automagically. Field Generator uses PHP’s openssl_random_pseudo_bytes() function to generate its random strings. It thus has both PHP >= 5.3.0 and OpenSSL as dependencies. Usage After installation, add rules through Setup > Field Generator. That’s it! Rules only run when first creating the page. For more information : https://github.com/plauclair/FieldGenerator Release : Version 0.9.0 This is the initial release. This is near stable and you shouldn’t be too worried to use it in production. Here is a screencast on how to use it.
- 29 replies
-
- 10
-
Getting ready for release, it’s ready to test. I just committed version 0.9.0 which adds the setup panel. https://github.com/plauclair/FieldGenerator You can see it in action here: I would really appreciate that you submit bug reports on GitHub if you find anything.
-
I’ve seen that, but it didn’t seem so flexible to store some kind of repeaters that I can easily loop through. Sure I could implement all config through json but to be honest that sounds way more of a pain than required. I really wish there was more documentation about creating modules, especially best practices.
-
It could very well be implemented using a database table but why go that way when PW makes all those calls free?
-
Thanks Soma, I just happen to have seen just that in apigen (class implements module). The reason I am using the system flag is that since the template and fields are required by the module which is part of the system, and that none of those templates or fields should be changed or removed by the user unless the module is uninstalled, it made more sense to make it system to prevent that. Does that make sense?
-
Just made a few commits to master. There is now an uninstaller, and the installer makes a few checks before trying to create things. https://github.com/plauclair/FieldGenerator It’s only missing the Setup panel now.
-
For those who want to try it, I have uploaded the project on GitHub. https://github.com/plauclair/FieldGenerator I strongly recommend you don’t use it in production for now. It runs correctly without problems, but the module doesn’t have an uninstall method yet. Since it creates system templates and fields, you won’t be able to delete those without going through a big hassle. Currently it also doesn’t have an administration panel, you’ll need to go (in tree) to Admin > Setup > Field generator, and create a new page using the fieldgenerator template. Page title has no effect apart from helping you remember what the rule is.
-
That’s right, it’s a bit similar and can most probably used for short urls, but I wanted it for different things and flexible enough. I often have to implement comments, ratings and other things over which I don’t have control on the page name, and I didn’t want to use automatic naming or dates or have to code that every time, just a generic, automatic random string. With this module, I don’t have to worry about it, just make a new page, set title and other fields and it just works by itself, don’t even have to set $page->name!
-
For those interested, here’s the working proof of concept. https://www.youtube.com/watch?v=x4PedafmKas I have decided to use parent ID instead but I’ll implement template support soon. Should have something ready to release within a few days.
-
Thanks Craig, I’ve looked into it more closely. I have basic functionality running already, I think I’m gonna have a lot of fun with these hooks!
-
I found the code that generates the page name (/wire/core/Pages.php). I’m contemplating making the changes in core and make it more flexible. Thoughts? if(!$page->name) { // auto-assign a name if possible $format = $page->parent()->template->childNameFormat; $pageName = ''; if(strlen($format)) { if($format == 'title') { if(strlen($page->title)) $pageName = $page->title; else $pageName = $this->_('untitled'); } else if(!ctype_alnum($format) && !preg_match('/^[-_a-zA-Z0-9]+$/', $format)) { // it is a date format $pageName = date($format); } else { // predefined format $pageName = $format; } } else if(strlen($page->title)) { $pageName = $page->title; } else { // no name will be assigned } if(strlen($pageName)) { // make the name unique $pageName = $this->wire('sanitizer')->pageName($pageName, Sanitizer::translate); $numChildren = $page->parent->numChildren(); $n = 0; do { $name = $pageName; if($n > 0) $name .= "-" . ($numChildren+$n); $child = $page->parent->child("name=$name, include=all"); // see if another page already has the same name $n++; } while($child->id); $page->name = $name; } }
-
@Soma I’ll look into it, it looks like I could simply add some way to make PW aware that it can use a random string generator instead of the date or title. @netcarver I already have a function that I reuse on every project for this, but I’ll look at your code thanks!
-
Where is it? Could you provide a link to documentation, I didn’t find it.
-
I’m seeking for your advice. I want to create a module that will allow generating unique IDs to fill different fields (in my specific case page names) according to different templates. Here’s the workflow I’m looking at: User creates a rule through Configuration -> Field generator that, given a template, will generate an ID. Here’s a mockup: I’d like if the page name could be automatically set right when the page is created. Also, what do I need to care about when updating the page, is there a risk it can be overwritten and is there a way to prevent that at all. They need to be permanent. I’d just like to know if it’s possible. I’ve begun looking at the different hooks, but there’s an overwhelming amount of them and I’m not sure where to begin. Would appreciate your input.