-
Posts
351 -
Joined
-
Last visited
-
Days Won
4
da² last won the day on November 27
da² had the most liked content!
Recent Profile Visitors
The recent visitors block is disabled and is not being shown to other users.
da²'s Achievements
Sr. Member (5/6)
240
Reputation
-
@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\.
-
da² started following Adding multiple pages to page reference field within a foreach php , Confused about Markup Regions - Best practice , Remove part of url and 3 others
-
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>
-
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.
-
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.
- 13 replies
-
- hooks
- pagereference
-
(and 1 more)
Tagged with:
-
*nothing* Just wrote a proposal until I found you already did that. 😅
- 13 replies
-
- hooks
- pagereference
-
(and 1 more)
Tagged with:
-
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. 🙂
-
This is an example from PHP documentation. Just saying that I discovered right now that constants are now allowed in traits since 8.2. ^^
-
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.
-
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.
-
So what do you think about this book after some weeks?
-
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. 🙂
-
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/" } },
-
Adding multiple pages to page reference field within a foreach php
da² replied to Liam88's topic in Getting Started
Oh OK you are talking about permissions, I thought it was about the field "view" option (open, closed, open not editable...). 🙂 -
Adding multiple pages to page reference field within a foreach php
da² replied to Liam88's topic in Getting Started
This should change nothing for the API, field is not editable in admin pages but from the API you can edit it. -
Adding multiple pages to page reference field within a foreach php
da² replied to Liam88's topic in Getting Started
Sometimes change tracking is not working properly and before to save the page we have to do this: $assetPage->trackChange('content_tags'); $assetPage->save();