-
Posts
341 -
Joined
-
Last visited
-
Days Won
3
Everything posted by da²
-
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(); -
Did you try this kind of selector? There's no loop, you directly get the repeater item. The part with "owner" is not mandatory, it depends if you want to do the search on a specific page or not.
-
Hi, maybe you can find help in this post:
-
It's hard to say what is your problem because $user->givenname should work if the template "user" has a field givenname with a value. So the problem is not this code, it's elsewhere. You shouldn't need this, I didn't even know it exists and I added 27 fields on the "user" template in my current project. 🙂 Where does $user variable comes from in your code? Does the "user" template have all the properties? What var_dump($user) returns?
-
Language selector: URL segments are lost when switching language
da² replied to da²'s topic in Multi-Language Support
If the developer have to manage segments, here is an update of the documentation example: <select onchange='window.location=$(this).val();'> <?php $urlSegments = $input->urlSegmentStr(); foreach($languages as $language) { $selected = ''; // if this page isn't viewable (active) for the language, skip it if(!$page->viewable($language)) continue; // if language is current user's language, make it selected if($user->language->id == $language->id) $selected = " selected=selected"; // determine the "local" URL for this language $url = $page->localUrl($language); // output the option tag echo "<option$selected value='$url$urlSegments'>$language->title</option>"; } ?> </select> Maybe this could be included in documentation, since it seems to me this should be the default behavior.- 1 reply
-
- 1
-
If using an AI, why not simply ask it to fix spelling? Then you do the search on the corrected word, AND the user provided (in case AI did a mistake itself).
-
Hello, I've recently updated a multi-language site to use the page names module. Reading the documentation there's nothing to do to make url segments to work with localized urls: Also documentation provides an example of a language selector: <select onchange='window.location=$(this).val();'> <?php foreach($languages as $language) { $selected = ''; // if this page isn't viewable (active) for the language, skip it if(!$page->viewable($language)) continue; // if language is current user's language, make it selected if($user->language->id == $language->id) $selected = " selected=selected"; // determine the "local" URL for this language $url = $page->localUrl($language); // output the option tag echo "<option$selected value='$url'>$language->title</option>"; } ?> </select> Problem: When I'm on a page mysite.com/fr/page-name/17175/, after switching language I go to mysite.com/fr/page-name/, the last url segment is lost and the page displays a 404 because it requires this segment. Is it the expected behavior? Is there something in the API I should use to make PW takes care of segments? Or do I have to manage the segments myself, using $input? 🤔
-
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?
-
I don't understand why this is necessary: $classLoader->addNamespace("ProcessWire", __DIR__ . '/classes'); I don't need this to get auto-load of custom classes.
-
Hi, I tried the same a while ago and it appears PW is forcing custom classes to be in site/classes directory. The code seems to be in ProcessWire.php: $cfg['paths']->data('classes', $cfg['paths']->site . "classes/"); Maybe you can overwrite this in your own config.php? Not sure if this is a good idea. ^^ But these classes dependencies can be in any package in site/templates/YourPackage (parent/abstract classes, Traits...). On my side the code I put in page classes is only related to the model part (getting/setting data), I don't use them to do rendering or controller stuff. The main part of the code is in my packages in site/templates. So I'm not really annoyed by the fact they have to be in the same directory, but I admit it would be better to put them in their related package.
-
Hello, When reading this, I think it's related with .htaccess not processed, I might be wrong but that's the first thing I would look at. How do you configure the VirtualHosts of each site? Is there a directive AllowOverride? https://stackoverflow.com/questions/35251032/how-to-create-virtual-hosts-in-mamp
-
How to solve this field value change issue while admin editing a page?
da² replied to PWaddict's topic in General Support
Another idea close to the @bernhard one: lock the quantity field so it's not editable add a field "quantity to add" in saveReady hook, load page without cache to get real quantity and update it with "quantity to add" field. -
@flydev I've played with ZipArchive recently and had some issues when unzipping on Linux (but not on Windows with 7zip), because I forgot to exit() PHP script after outputting headers and zip file. So I know a zip file can be opened on some software and not on other if it contains a problem. For the @MarkE issue, I'm wondering if it could come from the 2 lines in Duplicator.module where you update the zip archive without providing a flag in $zip->open()? Line 566 : if ($zip->open($pwbackup['zipfile']) !== true) { Line 939 : if ($zip->open($zipfile) !== true) { I don't really believe this solution, but I've seen a lot of posts like that when searching for my own issue: https://stackoverflow.com/a/17975009
-
Developer environment for ProcessWire 3.x on Litespeed with MariaDB?
da² replied to tinacious's topic in General Support
Hi, I don't think you'll see differences between MySQL and MariaDB, and LightSpeed supports .htaccess so this is a good news. To test it, it depends on your habits, I'm not a MacOS user, why not installing a Debian distribution in a virtual machine? MariaDB is the default database, and LightSpeed has a sh script to install it. On Windows I would use Linux WSL. There's also OpenLightSpeed in official Debian packages, but I don't know the differences: https://www.howtoforge.com/how-to-install-lomp-stack-openlitespeed-mariadb-and-php-on-debian-11/ -
Looks like a part of database has been copied? If I'm not wrong, fields are also referenced in fieldgroups_fields table that are referenced in templates table. So a template knows what field to display. But the main question is: why is not the database copied properly? What method do you use?
-
So there's a mistake related to the database. Or you are accessing the wrong one (check site/config.php), or the DB copy is wrong.
-
I had a look and only thing I found is to add a $config->sessionAllow = false; in site/config.php. So this is not usable since it will disable sessions for the web site too. Why not just including PW API at start of your main script? EDIT: @Ivan Gretsky Or you create a new include file (copy of index.php), like index-cli.php, to disallow sessions: <?php namespace ProcessWire; if (!defined("PROCESSWIRE")) define("PROCESSWIRE", 300); // index version $rootPath = __DIR__; if (DIRECTORY_SEPARATOR != '/') $rootPath = str_replace(DIRECTORY_SEPARATOR, '/', $rootPath); $composerAutoloader = $rootPath . '/vendor/autoload.php'; // composer autoloader if (file_exists($composerAutoloader)) require_once($composerAutoloader); if (!class_exists("ProcessWire\\ProcessWire", false)) require_once("$rootPath/wire/core/ProcessWire.php"); $config = ProcessWire::buildConfig($rootPath); $config->sessionAllow = false; // DISALLOWING SESSIONS <============== // Rest of file...
-
Best way to move a Processwire site to a new server 2020?
da² replied to modifiedcontent's topic in General Support
public function create($field, $operator, $value) { var_dump($operator); exit(); You could also use a PHP debugger but it needs some configuration. Yes there's probably some code doing a deprecated thing (in PHP 8.1), and not getting the expected result, maybe a code that prepare the $operator string. You may also check if you have some warnings or notices about deprecated usages, by using this handler in site/init.php. Then you'll find the logs in PW > logs > php-warnings. set_error_handler( function (int $errorNumber, string $message, string $file, int $lineNumber): bool { $errorString = "File \"$file\", line $lineNumber => $message"; wire()->log->save('php-warnings', $errorString); return true; }, E_WARNING | E_NOTICE); -
Hi, So, does the table usr_p624065_1.field_select_hidden_categories exist? 😁