Jump to content

da²

Members
  • Posts

    405
  • Joined

  • Last visited

  • Days Won

    5

Everything posted by da²

  1. I use many translate functions in static functions without issue. Looks like a strange issue, maybe a PHP version difference?
  2. Look closely what the loop is creating, something is missing. ? <tr> <?php foreach($countymatch as $match): ?> <td></td> </tr> <?php endforeach; ?> You should indent your code to make it more readable and easier to debug. For example this is way easier to understand at first look (I didn't test it): <?php $countymatch = $pages->find("template=county-match-result, year={$page->id}"); ?> <table> <thead> <tr> <th>Opponents</th> <th>Venue</th> <th>Points for</th> <th>Points against</th> <th>Result</th> </tr> </thead> <tbody> <?php foreach($countymatch as $match): ?> <tr> <td><a href="<?= $match->url ?>"><?= $match->title ?></a></td> <td><?php if ($match->home_away->title == 'Home') echo "<a href='{$match->home_match_venue->url}'>{$match->home_match_venue->title}</a>"; else echo $match->away_match_venue; ?></td> <td><?= $match->cheshire_points; ?></td> <td><?= $match->opponent_points; ?></td> <td><?= $match->match_result->title; ?></td> </tr> <?php endforeach; ?> </tbody> </table>
  3. Hello, First you should start from a valid table skeleton: https://developer.mozilla.org/fr/docs/Web/HTML/Element/table Then your loop is not creating rows but columns, <tr> is a row and should have only 5 items in your case, but you're adding in a single row as much <td> as you have matches. Also you need a "==" here: if ($match->home_away->title = 'Home')
  4. It's probably a bad server/PHP configuration, maybe this will help: https://stackoverflow.com/a/36455035 Or ask your provider, I have no idea what they do with PHP. That's why I only own dedicated Debian servers in VPS, it's the same price and you are 100 % free to manage system configuration yourself, without the need of using graphical tools that you don't really know what they do. It requires knowledge in Debian and Linux administration but with Google everything can be learned.
  5. It's up to you, I know PW supports at least up to PHP 8.2. But if you don't use any new PHP feature you can stay with PHP 7.4. You only need to tick the ones linked with your error messages.
  6. I have no idea how they configure PHP, you probably already know this page: https://faq.o2switch.fr/hebergement-mutualise/tutoriels-cpanel/selecteur-version-php You may also try to install missing PHP modules corresponding to your errors (see video). Usually on Debian I only need to add this modules "php-mysql php-gd php-zip php-mbstring" but on another Linux distribution you have more or less to install.
  7. What is your Linux distribution and how do you install PHP8?
  8. This returns only first level children. If you want grandchildren at any level I think you need to create a recursion function.
  9. Yes at least you'll get rid of errors if they prevent PW to work. There's also a database table "modules" that references installed modules I suppose, I don't know if it's preferable to remove module entry or not.
  10. Salut @Webjack, On va le faire en anglais si ça te dérange pas, ce sera compréhensible par tout le monde. ? Yes this is a PHP version issue, it's about union type "string | int" introduced in PHP 8. You have issues in your system installation, none of MySQL or other PHP extensions are found. These requirements are validated at the begin of PW installation. ProcessWire works fine with PHP 8+.
  11. You can hook "saved" method. When you don't want to trigger hooks on a page save you can use: $page->save(options: ['noHooks' => true]);
  12. @uzlander I'd use saveReady and isNew() to initialize a default value, so the hook only apply the first time page is created: $this->addHookBefore('Pages::saveReady(template=my-template)', function (HookEvent $event): void { $page = $event->arguments(0); if ($page->isNew()) { $page->myField = "myDefaultValue"; } }); Or like this, replacing isNew() by id=0 in hook selector: $this->addHookBefore('Pages::saveReady(template=my-template, id=0)', function (HookEvent $event): void { $page = $event->arguments(0); $page->myField = "myDefaultValue"; });
  13. It's hard-coded for now but I will eventually move it to a PW config page, so my clients can change it. Having it in a template wouldn't help because I highly discourage my clients to go in templates/fields area, it's way too much dangerous for a non-developer (their standard accounts can't access here).
  14. The first time I had a look to Drupal I didn't find how to create a basic page, like just... "can I create a template?", "where do I write php code?", "where do I add a <div>"? Sometimes I go in Drupal documentation, just having a quick look, there's a lot, a lot, a lot of documentation, there is so much to read, but for so little useful information. It's like a big wall where you would look for a door to pass through that you never find. I don't lose hope; perhaps one day I'll have enough motivation to find that door. ?
  15. So it seems this is field assignation that triggers change detection, it works like that: $pageSessions = $page->raceSessions; $pageSessions->removeAll(); foreach ($sessionsTemplate->raceSessions as $raceSession) $page->raceSessions->add($raceSession); $page->raceSessions = $pageSessions; // Assignation triggers change detection
  16. @MarkE This is a saveReady hook, page will be saved at the end.
  17. I think what is triggering changes detection may be field assignation: $page->myField = $newValue. But then I'm stopped by this bug.
  18. Hello, I was working on a hook that updates a matrix repeater. I have another hook that should trigger when this repeater is changed, and I found it is not triggered. So I thought that changes are not triggered by API changes (only user changes in admin), so that I should call the second hook myself. But I did another test with "title" field, and found it is triggered by API change. ?‍♂️ I plan to report the issue on GitHub, but want to ask here before in case I'm missing something. The following code updates the matrix repeater from another repeater, then I update title, then I check if repeater and title changes are tracked, and only title one is: protected static function onSaveReady(HookEvent $event, EveningRacePage $page, mixed $eventObject): void { /** @var RaceSessionsTemplatePage $sessionsTemplate */ $sessionsTemplate = $page->raceSessionsTemplate; $page->raceSessions->removeAll(); foreach ($sessionsTemplate->raceSessions as $raceSession) $page->raceSessions->add($raceSession); $page->title = $page->title . "1"; $changes = $page->getChanges(true); wire()->log->message("title changed" . array_key_exists('title', $changes)); // 1 wire()->log->message("raceSessions changed" . array_key_exists('raceSessions', $changes)); // 0 }
  19. Hey, I see your idea like having static properties, instances are pages and static properties are on template. I don't know it this is a good idea, on my side, since I discovered custom page classes I declare this on UserPage for example: public function getAvatar(): string { return $this->avatar ?: wire()->config->urls->templates . 'img/default-avatar.png'; } I could also have the default avatar on a generic configuration page.
  20. In my test I did an exit(), if I remove it it throws an error. ? $this->addHookAfter('InputfieldRepeater::renderRepeaterLabel', function(HookEvent $event) { $page = $event->arguments(2); $page->getForPage(); // Comment this line and there's no more error // exit(); // Or uncomment this }); Error comes after our call to getForPage(): It seems that calling getForPage() triggers an error later in PW code... Looks like a bug to report. In getForPage() source code we can see: // this probably can't occur, but here just in case $this->forPage = $this->wire('pages')->newNullPage(); Looks like it occurs @ryan ?
  21. Oh ok I see, so getForPage() works on my side (PW 3.0.228): /** @var RepeaterMatrixPage $page */ $page = $event->arguments(2); $templateName = $page->getForPage()->template->name;
  22. Hello, There isn't a getForPage() method on Page class. To access parent template it's simple: $page->parent->template->name.
  23. Damned, I have always thought that custom page classes were usable only in template.php files. ?‍♂️ This evening I wanted to hack PW to create a template/CustomPageClass mapping usable everywhere with PW API (get, find, etc), and in the first 3 minutes I found it was already there. ? This is huge, I love it and am already refactoring some code and twig templates with a custom UserPage, using Traits to share some implementation with my RawUser class (an optimized class from direct database query). I'm quite excited! ?
  24. There are 2 types of bookmarks, one defined in template and that can be disabled, and one that you create manually on bookmarks pages, selecting a parent page. The first one uses label defined in templates (or template name if not defined), that's the one I was talking about. I thought that was your question. The second one use parent page name, and I don't how you can change this, maybe with a hook?
  25. @Nick Belane In template configuration -> first tab > label. ?
×
×
  • Create New...