Jump to content

da²

Members
  • Posts

    364
  • Joined

  • Last visited

  • Days Won

    5

Everything posted by da²

  1. I won't help for reading a function name. 😆 I don't know the module, check the documentation.
  2. Question is: will the Javascript be aware of the changes on the field? I bet no, and that it will need to be reloaded. I confirm that, I had to remove these conditions on a page because it was totally bugged (3 or 4 fields with dependencies), reported the issue but nothing has been done. 😐
  3. Hi, My first though is about .htaccess. Is it the original one? Does the web server process it correctly and does the server have more rules (redirections...) that could interfere with the PW .htaccess rules? Could it be related with the 404 page configuration in config? $config->http404PageID = 27; Also check that no hook is doing that redirection, like a hook that would say: "redirect normal and guest user to home page if they try to access admin"? ^^
  4. Yes, you can do it by changing the parent page template sorting option. The child template doesn't change, only the sort option on parent page template. /blog/ sorts children: most recent first /events/ sorts children: date order ascending
  5. Hi, You don't need a hook, you can sort children on the parent page:
  6. If you have a search page that allows to search text in a lot of pages containing big texts, you probably need it. Do a performance benchmark with and without. Yes but without the mistake you did on the method name. 😁
  7. I didn't play with multilanguage image fields, but if it's the same behavior than with other multilanguage fields (probably) you have nothing to do: if a multilanguage field defines a value for the current user language, then this value is used, otherwise the default language value is used. EDIT : hmm, looks like there's no multilanguage image field, so language alternate fields looks like the only solution, and then a hook like @ngrmm proposed sounds good.
  8. Hi, In my experience we did that with project management softwares like Redmine, or Jira for a paid solution. You create user stories, tasks, estimate time and so on...
  9. Solution is here: https://processwire.com/modules/search-engine/ // Alternatively index just a single page (passing in a Page object): $modules->get('SearchEngine')->indexPage($page);
  10. On my side I backup DB only manually (I run a mysqldump script), I never want an automatic dump because it may backup a database in a dirty state. My goal is to keep a clean version of DB that could be installed on a fresh server.
  11. Hi, First thing I see is you are trying to display too much pagination. Ten elements is usually enough, with 3 dots in the middle: 1 2 3 4 ... 9992 9993 9994 9995. But then there's no really interest in displaying years. ^^ I bet the problem is only a design question: what kind of data do you want to display to the user? Is is truly ergonomic to display an infinite line of links? Wouldn't it be better to display only years at first, then when user clicks a year, display the pagination? Maybe think about it and you'll find a solution better for user and the developer. 🙂 Anyway, the solution will be a good designed MySQL query, but never to load "all" data.
  12. You are indexing all the site pages every time a page is saved. You should index only this page since the work for other ones was already done.
  13. @Alpine418 In PHP, classes are loaded with an autoloader that you can manage via composer (this is the common way). And ProcessWire comes with a composer.json file that you just have to edit, for example I edited mine like this: "autoload": { "files": [ "wire/core/ProcessWire.php" ], "psr-4": { "Rfro\\Rfrorga\\ProcessWire\\": "site/templates/", "ProcessWire\\": "site/classes/", "Rfro\\Rfrorga\\WebApi\\": "webApi/", "Rfro\\Rfrorga\\Cron\\": "cron/" } }, Now I can use any of this namespaces everywhere. In my custom classes I use base classes and traits located in site\templates\Php\CustomPage\Page\.
  14. At first I used regions, then markup regions, and I found that I wasn't happy about performances. I did some benchmarks and noticed that the time consumed to render the page was growing faster than the amount of data to render. For example, if I double the data, rendering may take 3x the time (just a random number, I don't remember values, but I think I saved them in a text file). That's why I switched to Twig, Twig is slower for small content but is robust with big content. And I like how it's easy with Twig to write clean readable code, reuse twig fragments several times, import, extend, include, embed... there's a lot of choice, and no performance issue when including twigs into twigs. For very small html snippets that I use everywhere in the site, and are closely related to a page/template, I also have a method on my custom page classes, that calls a "Renderer" instance associated with this page and print some HTML. I use it for example for the user cards that are displayed on almost all pages of the previous site I did: <div>{{user.renderer('card')}}</div>
  15. Hi @Alamut, You can do this with URL hook: https://processwire.com/blog/posts/pw-3.0.173/#telling-processwire-what-page-to-render Another solution is to create a template and a unique page "product-sheet" to display all your products. So the URL will always be the same except for the product ID.
  16. The message I deleted was answering this (I think so), but I was proposing the exact same solution as this: So I don't get what is the problem with this solution? Then you juste have to edit the selector string of the status field, so that it searches only statuses that have the same "course parent" as the current course. Something like selector="template=status, course_parent.id=page.parent.id". I'm not sure about the selector, I didn't use PW since a few months.
  17. *nothing* Just wrote a proposal until I found you already did that. 😅
  18. Ho nice, I think this is more a book that you should read when you are already a OOP developer and want to go further in structuring your code. Starting the book without OOP knowledge is quite a bigger challenge. 🙂
  19. This is an example from PHP documentation. Just saying that I discovered right now that constants are now allowed in traits since 8.2. ^^
  20. Usually languages uses this convention for constants, caps and underscore to separate words : Inputfield::COLLAPSED_HIDDEN I add a doubt but yes, PHP 8.2 supports constants in traits. <?php trait ConstantsTrait { public const FLAG_MUTABLE = 1; final public const FLAG_IMMUTABLE = 5; } class ConstantsExample { use ConstantsTrait; } $example = new ConstantsExample; echo $example::FLAG_MUTABLE; // 1 ?> About the hyphen in variable name, I bet most languages would refuse it, because hyphen is an operator.
  21. I add to Git site and wire. On wire I have some Git patches that I may apply again after updating to a new version, and each wire version may solve or add bugs, so I add it to version control. So .gitignore files exclude vendor directory and : I need some files in assets, so I exclude everything that is not needed and keep the rest. I also add the database.sql to Git, a clean version ready to be deployed on a new site. Everytime I do changes in admin I export the DB.
  22. So what do you think about this book after some weeks?
  23. To be honest I'm not an expert with composer, I did some research to configure properly PHP and found this way. It's working locally, working on production server, PhpStorm is not complying and generates the corresponding namespaces when I create a class... so I think this is good. 🙂
  24. Hello, Yes this is where I manage my namespaces and dependencies and it works fine. "autoload": { "files": [ "wire/core/ProcessWire.php" ], "psr-4": { "Rfro\\Rfrorga\\ProcessWire\\": "site/templates/", "ProcessWire\\": "site/classes/", "Rfro\\Rfrorga\\WebApi\\": "webApi/", "Rfro\\Rfrorga\\Cron\\": "cron/" } }, "require-dev": { "phpunit/phpunit": "9.5.28", "dbrekelmans/bdi": "^1.0" }, "autoload-dev": { "psr-4": { "Rfro\\Rfrorga\\ProcessWire\\": "site/src-tests/" } },
×
×
  • Create New...