Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 09/16/2024 in all areas

  1. addSuffix loads class if filename ends with suffix. processwire/wire/core/ProcessWire.php at 3cc76cc886a49313b4bfb9a1a904bd88d11b7cb7 · processwire/processwire (github.com) my setup. changed default "classes" dir with "models".
    3 points
  2. PageListCustomSort Github: https://github.com/eprcstudio/PageListCustomSort Modules directory: https://processwire.com/modules/page-list-custom-sort/ This module enables the use of a custom sort setting for children, using multiple properties. About This module is similar to ProcessPageListMultipleSorting by David Karich but is closer to what could (should?) be in the core as it adds the custom sort setting in both the template’s “Family” tab and in the page’s “Children” tab (when applicable). Usage Once a custom sort is set, it is applied in the page list but also when calling $page->children() or $page->siblings(). You can also apply the custom sort when calling $page->find("sort=_custom") or $pages->find("parent_id|has_parent=$id,sort=_custom"). Unfortunately this won’t work the same way sort=sort does if you only specify the template in your selector.
    1 point
  3. Hey @netcarver very interesting 🙂 I've never worked with them but from the demos these two look like very good candidates: http://fabricjs.com/ https://github.com/bubkoo/html-to-image
    1 point
  4. Ok, I will try to find whats going wrong. And just for the record: I'm currently using it, also in PW 3.0.241 with PHP 8.2, without any errors. (?!?)
    1 point
  5. A new page needs to be saved before you can add files or images to it. So try saving the new repeater page after you create it: // ... $contentRepeater = $page->content->getNew(); $contentRepeater->save(); // ... I suggest you install TracyDebugger because it would have shown you a error message that explains the problem when you tried to add a file to an unsaved repeater page.
    1 point
  6. Hmm, I don't need it on my side. Are you using the correct namespace? I added a directory Test in site/classes/, inside a class Foo with this namespace: <?php namespace ProcessWire\Test; class Foo{} And in a template.php I instanciate it: use ProcessWire\Test\Foo; $test = new Foo(); If you're using the same code, maybe it comes from my composer.json but I would be surprised. I updated the composer.json, but only to add my own namespaces. ** looking my composer.json and... Hoooooo yes I know why... 😁 ** "autoload": { "files": [ "wire/core/ProcessWire.php" ], "psr-4": { "Rfro\\Rfrorga\\ProcessWire\\": "site/templates/", "ProcessWire\\": "site/classes/", "Rfro\\Rfrorga\\WebApi\\": "webApi/", "Rfro\\Rfrorga\\Cron\\": "cron/" } }, I don't remember why but I added a namespace for site/classes. 🤔 Probably for the same problem as you... Could it be a cleaner way to solve your issue?
    1 point
  7. If you need to do it even earlier than using init.php: https://processwire.com/talk/topic/26875-page-classes-with-traits/?do=findComment&comment=222333 also see: https://github.com/processwire/processwire/blob/3cc76cc886a49313b4bfb9a1a904bd88d11b7cb7/wire/config.php#L1756
    1 point
  8. Hey guys, @da², @fliwire, thank you for your help. It pushed me in the right direction. I got my things done and wanted to share with whoever would find that useful. Here was my need: a specific folder to store some classes, usable easily across templates (ie "use Class" and not "include ...". These classes wouldn’t fit (IMO) into a DefaultPage class for separation of concerns matter. And I didn’t want to try to develop a module, seemed an overkill and time is running... I decided to store my custom classes files into some subfolders of the /site/classes folder. At first, I used a /site/src folder (and it worked), but as the classes folder already exists, I thought it made more sense to use this folder. This is my architecture ├── site/ │ ├── assets │ ├── classes/ │ │ ├── Repository/ │ │ │ ├── AbstractRepository.php │ │ │ └── ContactRepository.php │ │ ├── DefaultPage.php │ │ ├── HomePage.php │ │ └── Utils.php │ ├── modules │ └── templates └── wire For autoloading use PW autoloader, in put in init.php $classLoader = $wire->classLoader; $classLoader->addNamespace("ProcessWire", __DIR__ . '/classes'); Then the magic happens. My ContactRepository.php, for example : namespace ProcessWire\Repository; use ProcessWire\Utils; class ContactRepository extends AbstractRepository { // my stuff here... } and when I need it in a template file : namespace ProcessWire; use ProcessWire\Repository\ContactRepository; $contactRepo = new ContactRepository; $speakers = $contactRepo->getAllSpeakersAndModerators(); Remarque: In the init.php file, I tried with and without $classLoader->addSuffix("Repo", __DIR__ . '/classes/repositories'); // does not change anything $classLoader->addPrefix("Repo", __DIR__ . '/classes/repositories'); // does not change anything I can't really grasp in which situation this useful, and the doc is quite short... 😅 So with this file structure, I can really get a step further in logic handling and code maintenance. Hope someone will find this useful. Cheers
    1 point
  9. Hey @Stefanowitsch I'm not using SCSS in any project so I don't have a quick answer and I'd appreciate if you could debug this on your own and let me know if anything has to be changed in the module to make it work. The SCSS support has been added by a PR: https://github.com/baumrock/RockFrontend/pull/29 Maybe you can ping the author about the problem?
    1 point
  10. Sorry i wanted to write that i changed it to utf8mb4_unicode_ci. Here is query that i used to do it: ALTER DATABASE processwire CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ALTER TABLE field_body CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci Still - I cant save my emojis. ?
    1 point
×
×
  • Create New...