Jump to content

da²

Members
  • Posts

    309
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by da²

  1. I understand the idea, this is actually a problem that application might break if this setting change. But instead of adding methods I would remove the setting, no more choice between different return types, only Page|null (and PageArray for multiple). Simplicity... 😁 Obviously it would break actual sites deployed with PW, so maybe for a ProcessWire 4.0... ^^
  2. I use the false value, but I'd prefer a null value, this is more common. Globally I don't really like the NullPage usage in PW API, instead of a null value. Code is a bit less readable, and in both cases you'll end with an error when accessing a property/method on it, if you forgot to check the value. if (!$page) // Faster to write, easier to read if (!$page->id) if ($page instanceof NullPage) NullPage may be necessary in PW core code, but in my usage I don't see any advantage compared to a null value.
  3. I bet $contact is coming from a page reference field that is configured to return false when empty. So if $contact is optional, the code should verify its value before to use it and call renderContactSmall(). For the empty selector, it's necessary to investigate the code that generates it, and log value of variables it's using.
  4. When I need to load a fair amount of data I do custom MySQL queries. findRaw() is very fast too but I don't like to parse its results. Just be careful to sanitize data where needed (all texts at least). The downside is that it takes much more development time. But I become better in MySQL stuff. 😁
  5. If the user have an account: create a form with a select input listing languages, then set the selected language on current user and save. $of = $user->of(false); $user->language = $languages->getLanguage($form->language)->id; $user->save(); $user->of($of); $form->language is my select input, it's the language name. If user has no account, it all depends on how you want to manage languages, common solution is to use language URLs, /de/, /fr/, /en/... https://processwire.com/docs/multi-language-support/multi-language-urls/
  6. You are actually viewing the site with default language. Try this: user()->setLanguage("Tamil"); echo __("Welcome to our website");
  7. Ha, ok, I get it too, that wasn't a PW admin question. ?
  8. Hi, Language packs are not modules, you install them from each language page, accessible from menu Setup > Languages. Then you have a button to import a zip.
  9. @BarryP What is a "loss map"? Are you talking about this "Home" image without src value? Processwire templates are inside the directory site/templates. You probably have a home.php, that is the starting point for the home page display.
  10. I'm not a PHP expert, I use this language since a few years but only intensively since last year. And I just found the spaceship operator <=>. A few days before I implemented an ArrayUtils::floatCompare() because I found bugs in my code where I compared floats like int, because usort callback function return value is an int and I was returning "$float1 - $float2"... followed by the implicit cast to int... not perfect sorting. ? I know I've already read about this 'spaceship.' I remember the name, but probably it wasn't the right time to fully understand its meaning. ^^ Did you know this operator? EDIT : thanks to the moderator who pinned this topic, I owe you a beer! ?
  11. Why? I don't give names, I let PW create it from title.
  12. Is it faster to add START TRANSACTION and COMMIT in the sql file? In my current project I sometimes import 5000 pages using PW API, and with transactions (wire()->database->beginTransaction(); wire()->database->commit();) it is done in 20-30 seconds.
  13. Hi, If your page reference field can contain multiple pages, you should add pages like this: $page->sammelband_verweis->add($matchingPage); Also, for optimization, you should save the page outside of the loop: $of = $page->of(false); foreach ($page->children("include=hidden") as $child) { if (! empty($child->sammelband_text)){ // doing some sanitation to the field's content $SammlungTitel = extractTitleAfterYear($child->sammelband_text); $escapedTitle = $sanitizer->selectorValue($SammlungTitel); $matchingPages = $pages->find("template=publikation, include=hidden, title^=$escapedTitle"); if ($matchingPages->count() > 0) { $matchingPage = $matchingPages->first(); $page->sammelband_verweis->add($matchingPage); } } } $page->save('sammelband_verweis'); $page->of($of);
  14. I've reached the same conclusions when I tried with Profields Table. I use a lot the autocomplete field because the select is not good for hundred of pages. From what I understand, limitation is on both sides: the find() string selector, and the ProcessPageSearch. Just one needs to be improved to solve this limitation. The easier fix is probably ProcessPageSearch: we need a hookable method to replace results, like the getSelectablePages() of InputfieldPage, and like in other hooks we need the page and field from where the request was sent.
  15. I had a look at it, I remember trying to do the same with an autocomplete field except I tried to reference pages from a Profields Table, and never found a correct solution. What you can do is search for repeater items instead of the pages inside items. Or hooking into ProcessPageSearch::findReady to update selector, but it's not clean, I think only solution is to add "id=xxx|xxx|xxx|xxx|xxx|xxx|...." in selector. ? Or maybe hooking into ProcessPageSearch::executeFor and doing your own search. For the hooks you need to know on what page you are, I don't know how. EDIT: Except with a ugly hack, like adding in selector string "name=page.id", and so in ProcessPageSearch::executeFor you can get the page id with $event->return, do a search directly in repeater (like this) and finally format and return results.
  16. @Kiwi Chris Yes, page.vintage refers to the property vintage on the current page. I thought it was your goal, but I missed you are trying to reference item fields in repeater. If I understand good, in your page you have a page reference field with the selector string, and this field must reference the pages that are set in a repeater on the same page? Or is the page reference field inside the repeater too? ?
  17. @Kiwi Chris Try this: productVintage.id=page.vintage.id or: productVintage=page.vintage If you search by title, it would be: productVintage.title=page.vintage.title But I don't see any reason to search by title instead of id.
  18. @BIMAQ-Admin Take care that this properties in the destination site/config.php are the same as the original site: $config->userAuthSalt = 'xxx'; $config->tableSalt = 'xxx'; The procedure could be more simple, no need to install PW then delete the database. Just rsync the files between 2 servers (with some exclusions for sessions and cache), and use mysql_dump to copy database from old server to new one. This is how I replicate my dev environment to the staging server, except I also exclude site/config.php after it was initially uploaded and adapted to server config. Example of database copy from source server to destination, to run on source server: mysqldump --add-drop-database -uSQL_USER_SOURCE -pSQL_PASSWORD_SOURCE --databases DATABASE_NAME | ssh MY_SSH_USER@DESTINATION_SERVER_IP "mysql -uSQL_USER_DESTINATION -pSQL_PASSWORD_DESTINATION" rsync, to run on source server (BUILD_DIRECTORY is the main PW directory path, /var/www/SITE_NAME/html/ is the destination directory: rsync -avh --delete-delay --exclude-from=deploy-excludes.txt -e ssh BUILD_DIRECTORY SSH_USER@DESTINATION_SERVER_IP:/var/www/SITE_NAME/html/ deploy-excludes.txt: site/assets/cache/* site/assets/sessions/* I'm not 100 % sure about syntax for "cache/*", I use "site/assets/cache/" in my case. Idea in your case is to copy empty folder without content, in case PW doesn't create it at runtime. Note that I added a SSH key on destination server, it's why I don't need to specify SSH user and password in commands.
  19. Yes, sometimes I want to post some random message but I don't find a place for this. Today, I was looking for a Drupal forum, and when I found this, I thought it was created to discourage people from asking for help. ? Look at a topic, seriously...
  20. Hey, I think this forum could benefit from a pinned thread where we can talk about anything and everything without needing to create a new topic, like a pub conversation that lasts all night, but goes on for years. ? If you are a moderator and like the idea, please pin this topic, otherwise just delete it, I won't hold it against you. ?
  21. @kongondo https://flathub.org/apps/com.visualstudio.code-oss Like on Windows, or better. ^^ But I prefer PhpStorm, it's not free but way better than VSCode.
  22. Hi @jmclosas, Could you give more informations on your code, and the complete stack trace? I have a template "game-championship-summary" that uses the template file "events-summary", the custom class is named GameChampionshipSummaryPage, and this is working. I bet you wrote the $page->getTest() yourself (or it comes from a module), because in ProcessWire core I can't find a single "getTest". ?
  23. @froot Try to replace "label" by "getLabel()". https://processwire.com/api/ref/field/get-label/
  24. Yes, looks like there are a few bugs in change detection, I reported a similar one recently: https://github.com/processwire/processwire-issues/issues/1947 You could also try setAndSave('property', value) or save('property'), or reassigning the field to the page...
×
×
  • Create New...