Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 07/04/2020 in all areas

  1. This week I'm not bumping the version number just yet because I've got lots of work in progress. The biggest thing so far is something I hinted at last week. Basically, I like what the addition of the MySQL query expansion operators have brought (per posts last week and week before), but they also reveal what's lacking: something as simple as a search for "books" still can't directly match the word "book". But that's the most basic example. It's not a limitation of ProcessWire, but just the type of database indexes in general. I think it'd be amazing if ProcessWire had the ability of being really smart about this stuff, able to interpolate not just plurals vs. singulars but related words. In a perfect world, this is what query expansion would do (in addition to what it already does). But the reality is that it involves all kinds of complicated logic, rules and dictionaries; well beyond the scope of even a database. And it can be vastly different depending on the language. So this isn't something we can just add to the core and have it work. On the other hand, I figured maybe we should just put in a hookable method that just pretends the ability was there. Then people could hook it and make it respond with variations of words, according to their needs. The searches that use query expansion could then call this method and use whatever it returns... for when someday the ability is there. So I went ahead and added that hook — WireTextTools::wordAlternates(). And our database-searching class (DatabaseQuerySelectFulltext) now calls upon it, just in case an implementation is available. Well, after getting that hook added and having our class call it, naturally I wanted to test it out. So I got to work on it and came up with this module: WireWordTools. The WireWordTools module provides an API for English word inflection and lemmatisation. And it hooks that new method mentioned above, so that you can install it and immediately have it bring your searches to the next level. While it only helps for English-language searches, maybe we'll be able to add more languages to it, or maybe it'll lead to other modules that do the same thing for other languages. The expanded/alternate words are only used for searches that use the new query expansion operators, which are the ones that have a "+" in them: ~+=, ~|+=, *+=, **+=. They all can return similar results, but are weighted differently. Unlike most operators, where the logic is direct and you can expect them to always behave the same way, these query expansion operators are more subjective, and ones I think we should intend to keep tweaking and improving over time to continually improve the quality of the results they return. Basically, they are geared towards building site search engines, so I think it makes sense for us to pursue anything that makes them better at that, rather than aiming to always have them return the same thing. I am currently testing out the ~|+= operator ("contains any words expand") on our main site search engine here, along with the WireWordTools module. Finally, searching for "books" does match "book" too, and a lot more. More to be done here, but it's a good start hopefully.
    12 points
  2. I was going through the Hanna Code "Readme" in Bitpoet's editorial blog based off kongondo's Blog module and this particular line caught my attention: $f = $modules->InputfieldCheckboxes; $f->name = 'vegetables'; // Set name to match attribute $f->id = 'vegetables'; // Set id to match attribute $f->label = 'Vegetables'; $f->description = 'Please select some vegetables.'; $f->notes = "If you don't eat your vegetables you can't have any pudding.";//<<<<<<<<<<<< $f->addOptions(['Carrot', 'Cabbage', 'Celery'], false); $form->add($f); Very funny... ?
    4 points
  3. Hello @ all Today I want to share an inputfield/fieldtype to store 2 or 3 dimensions of an object. This fieldtype was inspired by the amazing fieldtype "Fieldtype Dimensions" from SOMA. This fieldtype was introduced in 2013 - so its time for a relaunch. This new fieldtype offers more possibilities than the old one. This inputfield/fieldtype let you enter max. 3 dimensions (width/height/depth) of an object (fe a product), but you can select if you want to display inputs for 2 or 3 dimensions. 2 dimension can be used fe for wallpapers or photos, 3 dimensions fe for furnitures or other objects. There are several configuration options for this fieldtype in the backend. set type (2 or 3 dimensional) set size unit as suffix after each inputfield (default is cm) set max number of decimals (default is 2) show/hide a hint to the user how much decimals are allowed If the number of decimals will be changed, the database schema for each dimension column will also change after saving the field in the backend. For example: If the schema for each dimension field in the DB is f.e. decimal(65,2) and you will set the number of decimals in the configuration to 3, then the schema in the DB will also change to decimal(65,3) after saving the inputfield. You can download this inputfield at https://github.com/juergenweb/FieldtypeObjectDimensions There you will find more detailed information and explanation too. If you find any bugs or you have an idea to improve it (also code improvements) please report it on Github. Have a nice day! UPDATE 14.06.23 / VERSION 1.2.2 I have re-written the complete fieldtype to be compatible with PHP 8.2 and refactored some of the methods and the database scheme. If you have downloaded the fieldtype before, please deinstall the old one and make a new install. I have added this fieldtype to the Processwire module directory. After it has been published, please download it from there.
    2 points
  4. I think this is a bug in ProcessWire. When you use the ~= operator, ProcessWire translates it into MySQL’s select /*[…]*/ match(field_title.data) against('+New York' in boolean mode) as _score_field_title_data1 /*[…]*/ order by _score_field_title_data1 desc The score it uses to sort is generated by the database according to the number of times the string appears in the text (probably more complicated than that, but whatever). The problem is that several results will have the same score, so the order among them is not deterministic. The database just does whatever it wants at that point, so the order may change inbetween queries, even if the queries are the same, but especially if they differ, even just in LIMIT and OFFSET. If you add "sort" to your selector string, ProcessWire will still use the score to sort, but only after your specified fields. What ProcessWire should do is ALWAYS sort by page id at the end, to keep the order deterministic. It might also be nice to make the relevance scores accessible in selector strings, so you could do something like "title|trader~='New York', sort=-title_relevance, sort=-trader_relevance, sort=-modified, sort=-id" Now you could have results in order of textual relevance, and if the relevance is equal, get the most current ones first, or whatever you desire. Obviously the id is a pretty stupid way to sort, but since it’s strictly unique, it’s a stable way to break ties, so I’d always put it last.
    2 points
  5. if ($child->id === $pid ) { $class= 'active'; // Why are you declaring it here for the 2nd time? } elseif ($template= "memorials" && $child->id === $parents ) { // $template == ... missing double equal sign btw $class= 'active'; } I think you get Undefined because you are overwriting class after the first declaration and then sometimes your if statements never run (depending on false conditions) and so $class is not set at that point.
    1 point
  6. OK, I figured it out. I transformed the values of the inputfields inside the sleepValue function to a json array and now the values will be stored in the database. public function sleepValue(Page $page, Field $field, $value) { // throw error if value is not of the right type if (!$value instanceof OpeningHours) { throw new \Exception($this->_('Expecting an instance of OpeningHours')); } $content = json_encode($value->data['hours']); $sleepValue = ['hours' => $content]; return $sleepValue; } So the responsible lines are $content = json_encode($value->data['hours']); $sleepValue = ['hours' => $content]; The problem of the storage was that the column 'hours' was not defined in the sleepValue method. This was the important part because without it the system doesnt know where to store the value.
    1 point
  7. Hi @elabx, thanks for the suggestion. I finally came up with a solution combining the hook and special names in the template flags. So with my example from above, I add a tag with the name allowedonly4-basic-b to the template that should be allowed only in the sub directory of basic-b, but not in other sub directories. $wire->addHookAfter('ProcessPageAdd::getAllowedTemplates', function($event) { $pages = wire()->pages; $parent = 'sub' == $pages->get(wire('input')->get->parent_id)->template->name ? $pages->get(wire('input')->get->parent_id)->parent() : new NullPage(); if(0 == $parent->id) return; $templates = $event->return; foreach($event->return as $template) { foreach(explode(' ', $template->tags) as $tag) { if('allowedonly4-' == substr($tag, 0, 13) && substr($tag, 13) != $parent->template->name && isset($templates[$template->id])) { unset($templates[$template->id]); } } } $event->return = $templates; }); With this combination I now can create templates allowed only for one or two defined sub directories.
    1 point
  8. Hi, module isn't maintained or tested anymore. I love PW, but at the moment I don't need / use it. Because of missing time I stopped web development / fun tasks some time ago...
    1 point
  9. I found the culprit. It wasn't Tracy. It was another module I probably should have suspected since it has never really worked out that well for me - despite being a good idea. Thanks for your effort in trying to help me debug this - coincidences and panic are a lousy combination.
    1 point
  10. UPDATE 2020-07-03 SnipWire 0.8.7 (beta) released! This update fixes some small bugs and adds an indicator for TEST mode: Added ProcessWire notice to flag SnipWire TEST mode Updated exchangerates API to handle unsupported currencies All modules and class files are now using ProcessWire's classLoader Fixed badges display when no refunds possible (in order details - refunds form) Fixed a page select problem with custom cart fields
    1 point
  11. Check this out: https://processwire.com/blog/posts/pw-3.0.137/#on-demand-mirroring-of-remote-web-server-files-to-your-dev-environment
    1 point
  12. Another change I had to make - the Awesomplete flyout sets a z-index of 1 - but ui-button in this theme also sets this to 1 and the hover layer to 0. I modified this in AdminThemeBoss/uikit/custom/theme/components/forms.less, line 122-135 button.ui-button { position: relative; z-index: 0; &:hover { z-index: 0; box-shadow: 0 5px 15px @theme-primary-color-rgba; +.ui-button { z-index: 0; } } } Changing the z-index values from 1, 1, 0 to 0, 0, -1 - so they'd hide behind the awesomeplete.
    1 point
  13. Hi @gornycreative this could work, yes. But I guess there would be 1000 edge cases that could make that setup fragile. I've used Kickstart on almost all installations for the last couple of months years ? and had no problems, but for example on my new live server I get a 500 (though the installation works afterwards, but I have to clean some files manually... likely a permissions issue). What I'd really like to have is some kind of simple and solid kickstart that installs RockMigrations and can then do whatever you want. Yeah, you always get the latest versions of PW and all the modules and you stay flexible in the setup (just comment out unneeded modules).
    1 point
  14. 1 point
  15. Hello fellow ProcessWire people! I published an article explaining how I migrated three years worth of running data from Garmin to ProcessWire: https://francescoschwarz.com/articles/running-on-my-own/ Have a great day! Cheers.
    1 point
  16. Thanks @BillH, I'm using the code from the Skyscraper demo: // check if there are any keyword searches in the selector by looking for the presence of // ~= operator. if present, then omit the 'sort' param, since ProcessWire sorts by // relevance when no sort specified. if(strpos($selector, "~=") === false) $selector .= "sort=name, "; I'm using renderPager(): $traders = findTraders($selector, 5); $pager = $traders->renderPager(); ... echo $pager; findTraders() is a slightly modified version of findSkyscrapers() function findTraders($selector, $limit=10) { // check if there are any keyword searches in the selector by looking for the presence of // ~= operator. if present, then omit the 'sort' param, since ProcessWire sorts by // relevance when no sort specified. if(strpos($selector, "~=") === false) $selector .= "sort=title, "; $selector .= "limit=$limit"; echo '<small>'.$selector.'</small><br />'; // now call upon ProcessWire to find the skyscrapers for us $traders = pages($selector); return $traders; }
    1 point
  17. Hello @ all! I want to share a simple fieldtype and inputfield to store address data with you. I have created this inputfield for learning purposes and it has no fancy functionality. It is simply for storing address data such as street, number, postalcode and so on in one table. As an addition you can store latitude and longitude too, so you can use them in maps. Here is a screenshot of what it looks like: You can select which fields are mandatory and you can choose if the inputs for longitude and latitude should be displayed. These settings can be configured in the field configuration. If you find this inputfield useful you can download it at https://github.com/juergenweb/FieldtypeSimpleAddress There you will find a detailed explanation. If you have an idea of an usefull feature that can be added or you have detected a bug, please report it in my github account.
    1 point
  18. But that's kind of the similar case as many of the Modules, with their last updates being years old. Are they no longer being updated because the developer lost interest in updating it? OR they work perfectly well still, with no need to update? lol, it could go both ways. It's a pleasant surprise when I test out an old module and it works perfectly with the later version of PW ❤️
    1 point
  19. I know you asked for a configuration but, maybe hook here? <?php $wire->addHookAfter('ProcessPageAdd::getAllowedTemplates', function($e){ $templates = $e->return; $specialTemplate = wire('template')->get('specialOne'); $parent = $pages->get(wire('input')->get->parent_id); if($parent->template != "sub"){ unset($specialTemplate->id, $templates); $e->return = $templates; } });
    1 point
  20. In the blog post last week we looked at some of the two-factor authentication system upgrades, like the new “remember this computer” feature. This week I finished off the remaining parts, as well as released new versions of both the TfaTotp and TfaEmail modules. Auto-enable TFA support We now have auto-enable support (forced 2FA), which lets you setup two-factor authentication for users, without their input (if they haven’t enabled it already). This is a good way to add a lot of security for very little work. Currently, the module that supports this is the TfaEmail module. That’s because it’s a safe bet to assume the user has access to their email, even if they haven’t specifically setup 2FA. So email is a very good way to nudge people into 2FA, and people are already used to this, as many online services now do it. Considering that the computer can now be remembered, I think it’s unlikely you’ll get any complaints from users. Setting up auto-enable is really simple. Grab the latest version of the TfaEmail module and install it. Then go to your ProcessLogin module settings (Modules > Configure > ProcessLogin) and you’ll see an option there to select Email in the “Force two-factor authentication - Type” field. If you want to limit this to specific roles, then you can also do that here. If you don’t select any roles, then it applies to all roles. Once setup, any user logging into your admin will be asked to enter an authentication code sent to their email, and they’ll need that code to complete the login. Chances are they’ll also click that “remember this computer” checkbox so that they can skip the code on future logins. TfaEmail version 2 The new version of the TfaEmail module also lets you now configure what WireMail module you want it to use for sending authentication emails. If using multiple mail sending services, you’ll want your most reliable and fastest email sending service to handle these kinds of transactional emails. TfaTotp version 4 Once users understand the benefits of 2FA, chances are they’ll want to upgrade to TOTP, where they can use a dedicated authenticator app. The ProcessWire TfaTotp module got several upgrades this week. The biggest was the addition of a locally hosted QR code generator (QRCode for PHP by Kazuhiko Arase). No longer does it have to rely upon an external service to generate QR codes (previous versions used Google Charts for QR code generation). In addition, the TOTP TwoFactorAuth library has been updated to the latest version. Moving those modules to the core Speaking of those two modules (TfaEmail and TfaTotp), thanks for your input last week about their inclusion in the core. It sounds like most think it’s a good idea, so I think we’ll go that route. But I need a little more time to do that, so going to hold that update and the 3.0.160 version bump for next week. Coming next week: Useful new selector operators Next week I’ve also got a couple of special new text-matching operators being added to our selectors system that I think you are going to really like. They are operators that are especially useful to those building text search engines, and ones that I’ve found so useful this week that I wish we’d had them since the beginning. I’m excited to add those into 3.0.160 and tell you more about them next week. By the way, while 3.0.160 isn't officially the version on the dev branch yet, if you download the current dev branch version (3.0.159), all of the TFA updates mentioned above are present and ready to use.
    1 point
  21. We recently launched The Power Supply Shop, an e-commerce store built using a combination of ProcessWire and SnipCart. The site has in excess of 120,000 products and variations, making heavy use of page references as well as SnipCart's "any page can be a product" approach. The site pulls in its data from an external MS SQL database several times a day. At a glance, the site uses: ProCache - as well as WireCache for some heavy product listing pages (50k+) FormBuilder @adrian's Tracy Debugger A modified version of @Soma's Ajax Search @mtwebit's fantastic Tasker and DataSet modules. And that's about it on the module front. For other libraries we're only really using FancyBox.js for product galleries and Anchorific.js for guide pages. At present the site is geared towards the UK, but if and when this changes I'm looking forward to delving into multi-languages with ProcessWire, something I haven't really worked with yet!
    1 point
  22. Actually class_exists() should work, but WillyC missed an important part. ProcessWire doesn't include module files that aren't autoload unless some information about them is requested, like $modules->getModuleInfo("className"), or the like. In the same manner, a class_exists("className"); call triggers the autoload mechanism and causes the file to be loaded. But you can prevent that by specifying false as argument 2 to class_exists(): if(!class_exists("ModuleName", false)) { // module is not loaded }
    1 point
×
×
  • Create New...