Jump to content

da²

Members
  • Posts

    346
  • Joined

  • Last visited

  • Days Won

    4

Everything posted by da²

  1. Ho yes, tthat's the good way to get module instance. ? But the original issue about editor isn't solved, for example if you want completion on this module by adding a php comment it won't work. /* @var TextformatterMarkdownExtra $md_formatter */ Maybe VSCode PHP extension is not parsing .module files by default, and maybe that's configurable? I used VSCode for a few years but use PHPStorm now and will never go back. ^^ In PW admin, in your field configuration > Details > Formatter, select the formatter for markdown. Then you just use $page->field to get the formatted value.
  2. Hello, You probably have to configure you VSCode project base directory on processwire directory (parent of "site" and "wire" directories where the modules are located).
  3. @adrianOK I didn't know. Since the Upgrades module is backing up DB I thought it was updating itself.
  4. The Upgrades module backup and upgrades the database, so I don't think you can achieve an update without using it, or at least it looks dangerous as you don't really know if something is missing in DB.
  5. @louisstephensYou didn't upgrade the database? If no, it's expected to have issues. Usually upgrades are done by installing module "Upgrades", then going to Configure > Upgrades. So I would suggest reverting your changes and follow this procedure. You don't have to manually backup files and database (of course you can as a double security), as it will be suggested by the Upgrades modules. Note that in case of errors you can check web server and PHP logs on your server.
  6. Hello, I don't have this class, but I don't see a "fields" property on FormBuilderForm class, nor on its super-classes. But maybe you can do this using "listFields" property and getFieldByName().
  7. You are referring to an echo in a template code that you see twice? That's expected. The code is not ran twice, I don't remember exactly how it works but your echo is like catched by render buffer, in addition to be displayed one time immediately.
  8. Hello, Did you read at least the first 3 sections here ? https://processwire.com/docs/multi-language-support/ You'll find different ways of managing languages.
  9. Some answers from Google: https://developers.google.com/search/docs/specialty/international/managing-multi-regional-sites
  10. Hello, Example in ready.php: $this->addHookBefore('Pages::saveReady()', function (HookEvent $event): void { /** @var Page $page */ $page = $event->arguments(0); $default = wire()->languages->get("default"); $english = wire()->languages->get("english"); $page->of(false); /** @var LanguagesPageFieldValue $field */ $field = $page->title; $defaultTitle = $field->getLanguageValue($default); if ($defaultTitle && !$field->getLanguageValue($english)) $field->setLanguageValue($english, $defaultTitle); $page->of(true); } );
  11. I don't know your module's code so I can't be specific, but seeing it's 3000 lignes long I think the main idea would be to split responsibilities into different classes. The Single-responsibility principle says that each class should only manage a single thing. It makes code cleaner, easier to manage and to test in the future. I'm saying this without knowing the code so it's just generic ideas. If your module manage fields, templates and migrations, you could add classes FieldBuilder, TemplateBuilder, MigrationManager... The module API would be something using fluent interface like this (OK I said that changing API is not necessary and I'm changing it... ^^): $myField = $module->newField()->type(FieldType::INTEGER)->name('foo')->min(1)->max(10); $myTemplate = $module->newTemplate()->name('bar')->addField($myField); With newField() and newTemplate() methods returning a FieldBuilder and a TemplateBuilder. The benefit is to move field or template specific code in classes that manages only this. Just some thoughts... ?
  12. Hello, Without code it's hard to help you. I found that this error is thrown by PW, Wire.php: protected function ___callUnknown($method, $arguments) { if($arguments) {} // intentional to avoid unused argument notice $config = $this->wire()->config; if($config && $config->disableUnknownMethodException) return null; throw new WireException("Method " . $this->className() . "::$method does not exist or is not callable in this context"); } So it looks like you are trying to call this method on a Page instance, and not on an instance of your custom page class.
  13. Refactoring doesn't mean an API change. If the only problem is to have 3000 lines in a single file, it can also be splitted in several small classes without changing the module API.
  14. I'm not using any third party module for languages. I don't have Modules > Configure > LanguageSupportPageNames. I only know a single way to bootstrap PW, including index.php like you do. Getting title of the page returns it in selected language, but using render() outputs the title in default language. For the test, be sure that your english language is not the default one, or obviously it will work. I'm using PW 3.0.210. <?php use ProcessWire\Languages; use ProcessWire\Pages; /** * @var Pages $pages * @var Languages $languages */ include __DIR__ . "/../vendor/autoload.php"; include __DIR__ . "/../index.php"; $languages->setLanguage('english'); echo($pages->get(6012)->render('title') . "\n"); // Outputs english echo($pages->get(6012)->render() . "\n"); // Outputs french (default language) EDIT: I'm using Twig for template views.
  15. render() uses the language only if a field is specified: $languages->setLanguage('english'); echo($pages->get(5998)->render('title')."\n"); I had a look to PageRender class about languages but didn't find useful information.
  16. I made a quick test, and this is strange because for me the render() method always uses default language (even if language is well managed in templates on frontend). This code works: $languages->setLanguage('default'); echo($pages->get(6012)->title."\n"); $languages->setLanguage('english'); echo($pages->get(6012)->title."\n"); $languages->setLanguage('default'); echo($pages->get(6012)->title."\n"); But this one doesn't, it returns default language instead of english: $languages->setLanguage('english'); echo($pages->get(6012)->render()."\n"); I'm testing by bootstrapping PW so I also tried to force output formatting and this doesn't change, but I feel this may be related with using this code from a bootstrapped code instead of a template code (because translation works in templates). I tested and I'm right: the last code is working in a template code but not in a bootstrapped one. So render() method looks like to have a particular behavior (bug?) with language management when bootstrapped. Tested with PW 3.0.210. EDIT: To conclude the test, I added this code in a template, to see if multiple langage changes are working, and yes it is: $languages->setLanguage('english'); echo($pages->get(6012)->render()."\n"); $languages->setLanguage('default'); echo($pages->get(6012)->render()."\n"); $languages->setLanguage('english'); echo($pages->get(6012)->render()."\n");
  17. System wide on Linux, if you have full access to your server there's also fail2ban: https://en.wikipedia.org/wiki/Fail2ban
  18. Hello, Are you sure your english language name is "en"? What is the output of this code: foreach (wire()->languages as $lang){ echo "$lang->name, "; }
  19. What do you need to understand? $page->author is a Page Reference field that can list multiple authors pages, so authors are stored in a PageArray, a kind of array dedicated in listing ProcessWire pages. So in your loop, $item is a Page instance using the template "author", and the Page class has a property "title" that corresponds to the title filled in this author's page admin.
  20. It's particular to call a function by a string. 99.99 % of the time you have better to do.
  21. In PW admin, create 2 fields of text (simple text or HTML, with appropriate formatter and editor), "my_page_header_1" and "my_page_header_2", go to the template of this page and add the 2 fields, and finally edit the page and fill the texts.
  22. Maybe with URL rewriting? Like a web server rule to transform URL like /concepts/My_Test_File4$$$.pdf/ to /concepts/?fileName=My_Test_File4$$$.pdf So old links are still working.
  23. Hello, Reading the documentation this is the expected behavior: But you can use get parameter: /concepts/?fileName=My_Test_File4$$$.pdf wire()->input->get->text('fileName'); It's maybe better to use an url encoded PDF name with php urlencode(): /concepts/?fileName=My_Test_File4%24%24%24.pdf urldecode(wire()->input->get->text('fileName'));
  24. Hi, This is called Markup Regions, it's targeted to ease templating (like Twig would do but only in PHP): https://processwire.com/docs/front-end/output/markup-regions/ If you use this, prefer to do it with the pw-region tag as it is better optimized (check the documentation). EDIT: I forgot to mention you can disable Markup Regions in site/config.php with $config->useMarkupRegions = false; Then you may also want to disable $config->prependTemplateFile if this file is no longer necessary. But if you want to use regions, you'll find in documentation that you can prepend/append/replace the _main.php tags with tags in templates, to solve the problem you are facing.
×
×
  • Create New...