Jump to content


  • Posts

  • Joined

Everything posted by Remi

  1. I've tried that before. It doesn't return any results :/ But when I use this selector: $selector = "children.template!=payment"; I receive all pages without children using "payment" template.
  2. SOLUTION below Yep. It works. Corrected code: $selector = "template=invoice"; $results = $pages->find($selector)->not("children.template=payment"); // or: $results = $pages->find("template=invoice")->not("children.template=payment"); // Doesn't work correctly (doesn't exclude pages with children.template=payment (PW 3.0.62 & 3.0.96)): $results = $pages->findMany("template=invoice")->not("children.template=payment"); It also executes 0,5-2 times faster than first working script. I've tried to use findMany method, but it doesn't work with not method.
  3. Hi! I would like to build selector to get pages without children using one template. // Doesn't work: $selector = "template=invoice, children.template!=payment"; // Works but in opposite way I want: $selector = "template=invoice, children.template=payment"; // Works, but it's useless because "invoice" can have other templates as children $selector = "template=invoice, children.count=0"; // Code below works but it gets huge amount of data from DB first :/ $selector = "template=invoice"; $results = $pages->find($selector); foreach ($results as $result) { $hasPayments = $result->hasChildren("template=payment"); if (!$hasPayments){ $content .= "Blablabla"; } }
  4. Hi! I've had a problem with uploading PNG files into Image field. I've had an error: Error: Uncaught Error: Call to undefined function ProcessWire\utf8_encode() in /var/www/domain.com/public_html/wire/core/PWPNG.php:117 Stack trace: #0 /var/www/dksb.turala.com/public_html/wire/core/PWPNG.php(31): ProcessWire\PWPNG->_parsepngstream(Resource id #155, 'image.260x...') #1 /var/www/dksb.turala.com/public_html/wire/core/ImageInspector.php(203): ProcessWire\PWPNG->loadFile('/var/www/domain...') #2 /var/www/dksb.turala.com/public_html/wire/core/ImageInspector.php(129): ProcessWire\ImageInspector->loadImageInfoPng() #3 /var/www/dksb.turala.com/public_html/wire/core/ImageSizer.php(102): ProcessWire\ImageInspector->inspect('/var/www/domain...', true) #4 /var/www/dksb.turala.com/public_html/wire/core/Pageimage.php(479): ProcessWire\ImageSizer->__construct('/var/www/domain...', Array) #5 /var/www/dksb.turala.com/public_html/wire/core/Pageimage.php(346): ProcessWire\Pageimage->___size(260, 0, Array) #6 /var/www/dksb.turala.com/public_html/wire/core/Pageimage.php(632): ProcessWire\Pageimage->size(260, 0, (line 117 of /var/www/dksb.turala.com/public_html/wire/core/PWPNG.php) In this case I've had to install PHP-XML library for PHP-FPM deamon. On CentOS 7 it's: yum install php-xml And after that I've had to restart PHP-FPM deamon: systemctl restart php-fpm I hope this solution will help others with the same problem.
  5. I'll try that It works!
  6. Hi! I've got a page with text area where user can check some codes divided by space, semicolon or comma. I can use two solutions to search for these codes: First method: $prCodesArray = preg_split('/[\\s,;]+/', $prCodes, -1); $selector = "title=" . implode("|", $prCodesArray) . ", template=pr-code, include=all, limit=100"; $prCodePages = $pages->find($selector); $prCodeCount = count($prCodePages); if ($prCodeCount) { foreach ($prCodePages as $prCodePage) { $content .= $prCodePage->title . " - " . "<span title=\"". $prCodePage->parent->pr_code_group_description . "\">" . $prCodePage->parent->title . "</span> - " . $prCodePage->pr_code_description . "<br>"; } } else { $content .= $prCode . __(' - Not found.') . "<br>"; } Advantages: + it's fast ~0.21s for ~40 codes. Disadvantages: - alphabetical results sorting while I want input order, - doesn't show not found codes. Second method: $prCodesArray = preg_split('/[\\s,;]+/', $prCodes, -1); foreach ($prCodesArray as $prCode){ $selector = "title={$prCode}, template=pr-code, include=all, limit=10"; $prCodePages = $pages->find($selector); $prCodeCount = count($prCodePages); if ($prCodeCount) { foreach ($prCodePages as $prCodePage) { $content .= $prCodePage->title . " - " . "<span title=\"". $prCodePage->parent->pr_code_group_description . "\">" . $prCodePage->parent->title . "</span> - " . $prCodePage->pr_code_description . "<br>"; } else { $content .= $prCode . __(' - Not found.') . "<br>"; } } } Advantages: + sorting like input order, + shows not found codes. Disadvantages: - it's slow as hell ~2.5s for ~40 codes. Is there any solution to join advantages of both methods? Also, as you can see I have to use include=all statement in my find methods and I don't know why. I've used Import Pages from CSV module. All codes (pages) are published and there is no access control on any of them.
  7. I've managed to do this module on my own. I can change it to store standard tables of text if somebody would be interested in that. It's possible to change order of the rows on the fly
  8. Yes. I don't understand why. But I've changed module name and made small changes inside. Order of the calls isn't important, now.
  9. I'm working on that, but I've got some problems... On Edit Page I don't receive values for subfield clean from DB. But if I will put them, then they are stored in DB. I can also see them on default view page (See update). I've got a problem on view page. Value of sort is always 0. Can someone help me with these problems? Update: I've solved first problem. I've changed order of 2 lines in protected function renderRow() in InputfieldTranslations.module: $clean = $this->sanitizer->entities($translation->clean); $translation = $this->sanitizer->entities($translation->translation); Why it works and this don't: $translation = $this->sanitizer->entities($translation->translation); $clean = $this->sanitizer->entities($translation->clean); FieldtypeTranslations.module InputfieldTranslations.module Translation.php TranslationArray.php
  10. dragan - I can do that by using another field. But it will make my site slower. I have ~30k pages with translations. My template has these fields: title * transcription abbreviation * part_of_speech article translation * definition * use_case * * - searchable I would like to switch field translation to something similar to Event fieldtype. Even without translation_plain it will be better for me. One word (page) can have many translations. It will also make search more accurate. I would like to sort translations by hand when they are already typed (in the Admin frontend). Take a look: Before: https://www.dropbox.com/s/yp4b5cb68aqr0pg/PW-Before.png After: https://www.dropbox.com/s/jhk8o51ws46ukqc/PW-After.png
  11. I'm working on dictionary. Basically it works fine. People very often type words in search field without national letters (like in old version based on Glossword). Because of that, search doesn't find all similar words. Examples: User want to find: sąd <court> User type: sad <orchard> Search found: sad (it should find also sąd) User want to find: łaska <mercy> User type: laska <stick> Search found: laska (it should find also łaska) Changing DB collations will solve this problem only partially. That's why I want to store two subfields with the "same" data. I believe it can be optimized to save translation_plain only if there are natonal letters in translation subfield.
  12. Hi! I need a new fieldtype for my project. Basically it will be a modification of Events Fieldtype, so that it shouldn't be hard to do. My field don't need "date" part. I would like to store in DB subfields: sort, data (translation), translation_plain. I don't need "date" subfield. I believe that "sort" subfield is clear. Translation and translation_plain subfields will store a short text (like in title field). Translation_plain will have almost the same value as translation. The difference is, that I don't want to have any national letters in this field. They should be converted to ANSI. For example: ą -> a, ę -> e, ś -> s, ł - > l, etc... I need this behavior to make my search less accurate (YES - I need that). That was a backend. Now the admin frontend: Translation_plain subfield should be hidden (backend or js should take care on conversion). I want to change order of subfields by hand. Like in Repeater module. Thats all.
  13. For my needs suffice shared hosting, because right now I don't have more than 4700 views per day. And it's done on Glossword which is much slower than PW.
  14. You will find these changes pulled by me on github. Another idea: In some cases using %LIKE method can be useful for someone. So, there is room for the next selector (last possible to use with MySQL?). I don't need that, but if You don't have enough time, I can make some changes in core files.
  15. Well, I would like to edit my pages on admin site, but I would like to remove some things from forms. For example: when I've got repeatable field (only one) I don't need "tables" like: My Repeatable fields > Repeatable fields 1 > My field + Repeatable fields 2 > My field + Repeatable fields 3 > My field, etc... I would like to have it displayed this way: My Repeatable fields > My field + My field + My field.
  16. I've done some research and I've got what I wanted. First issue It's not so important for me right now, but I will check that later. Second issue I've got results similar to my old CMS I'm using shared hosting, so I can't modify MySQL configuration files. I have to use LIKE method, but with standard selector %= I had too many unwanted results. I've decided to add extra selector %^= which use SQL LIKE method but gives me what I wanted To do that I had to modify 2 files in ./wire/core folder: DatabaseQuerySelectFulltext.php: // At line 76 I've added: case '%^=': $v = $this->db->escape_string($value); $v = preg_replace('/([%^_])/', '\\\$1', $v); // prep value for use in LIKE $query->where("$tableField LIKE '$v%'"); // SLOW, but assumed break; Selector.php: // At line 147 I've added: Selectors::addType(SelectorContainsLikeStarts::getOperator(), 'SelectorContainsLikeStarts'); // At line 226 I've added: class SelectorContainsLikeStarts extends SelectorContains { public static function getOperator() { return '%^='; } } After that, I can search for short words using LIKE% method intead of %LIKE% which gives me less but highly wanted results It's similar to ^= selector. I've proposed changes at GitHub. DatabaseQuerySelectFulltext.php Selector.php
  17. Is there a fast and easy way to create a custom edit page only for one content type (pages using same template)?
  18. Regarding first issue - I will check that later. About second issue I've got page: title: hus translation (my field): dom So, I want to find hus (page) by searching for: dom. After all, I'll check everything later tonight.
  19. About first issue: It looks that search engine use character replacement from Page Name module, so I know how to fix that. But what about second issue?
  20. Hello again! I'm still working with my PW powered site. I really love PW, but I've got problem with searching engine, while this is the most important part of my site (norwegian to polish dictionary) My searching rules: if (strlen($q)<=4) { // My sollution for short words: $matches = $pages->find("title|translation=$q, sort=title, limit=100"); // $matches = $pages->find("title|translation|definition%=$q, sort=title, sort=translation, limit=100"); // $matches = $pages->find("title|translation|definition^=$q, sort=title, sort=translation, limit=100"); } else { $matches = $pages->find("title|translation|definition~=$q, sort=title, sort=translation, limit=50"); } Some examples: Search word: sąd Results: domstol sąd frukthage en sad Search word: bąk Results: bak za, z tyłu, w tyle bak en pośladek, tył rørdrum en bąk So it looks that ą = a :/ Can someone tell me why? Another problem: When I'll change search querry to: $matches = $pages->find("title|translation|definition%=$q, sort=title, sort=translation, limit=100"); and I'm searching for: dom ("house" in english and "hus" in norwegian) I've got these results: advisere ogłosić, powiadomić aktivitetshus et dom kultury alderdom en starość aldershjem et dom starców ane przeczuwać, domyślać się, podejrzewać ane - aner - ante - ant etc... while I don't get hus in the first 100 matches :/ When I'll change search querry to: $matches = $pages->find("title|translation|definition%=$q, limit=100"); It's a little bit better, but still hus is very far from beginning of the search results. How can I improve that? Is there any rule to sort results by match?
  21. I'm still working on my PW site and it's hard to say when I'll finish. But when my site will be finished I can also write my "story".
  22. apeisa has right. In some cases, switching from Drupal will be complicated. I've spent a lot of time to find the best and the fastest method to export my nodes. For example: Node export module is good to export nodes one by one, but not lot of them at once. On my site I've used simple taxonomy (for repeatable words related to my pages) and I don't have any pictures related to my dictionary right now. And what's the most important - I have simple page tree (almost all of my pages are using the same template in PW). My current site is based on Glossword. It's dictionary/glossary CMS. It's very limited system in many aspects. So, my first thought was to switch to Drupal. I've done that. And the nightmare begun: - database (with 28k "pages") growned from 23MB (Glossword keeps data in XML format in database (sic!) and also templates there!) to over 200MB in Drupal!!! - Drupal with many custom fields is extremely slow. Drupal's support recommended me to switch my hosting to a dedicated server :/ I've lost few months on fighting with Drupal, just to make it faster. Finally I gave up. In the meantime I've tried other CMS'es without any bigger success. So, right now I'm switching my site to ProcessWire. Maybe there is many things to improve in this system, but I don't care about that, because PW is lightweight (15MB DB with 28k pages!!!), fast as hell - at least as Glossword and at least flexible as Drupal. P.S. About relations between pages and taxonomy (constant taxonomy in my case). I've done that this way (simple example): 1. I've exported relations from Drupal with names of articles (en, ei, et, etc... - words related to nouns), 2. In PW I've added "articles_RAW" and "articles" fields to my template and made similar structure of "taxonomy" like I had in Drupal, 3. Using CSV Page Import Process I've imported articles to "articles_RAW" field together with the rest of data (title, translation, etc...), 4. I've made simple script in JS for Scriptish (for Firefox) to set up "articles" field (based on "articles_RAW"), clear this last field and finally save a page. One by one. I know, that it's not the best method, but it works for me.
  23. I'm glad to see that everybody here see this problem I hope, that it will be resolved as soon as possible.
  • Create New...