Jump to content

da²

Members
  • Posts

    275
  • Joined

  • Last visited

  • Days Won

    3

da² last won the day on December 7 2023

da² had the most liked content!

1 Follower

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

da²'s Achievements

Sr. Member

Sr. Member (5/6)

177

Reputation

  1. Probably here you should catch Error too: catch (\Exception | \Error $e) I use similar code with Twig, rendering an error template if any error. class Twig { public static function render(string $name, array $parameters = []): void { if (NoticeManager::hasNotice()) $parameters['rfroNotices'] = NoticeManager::render(); $parameters['templatesUrl'] = wire()->config->urls->templates; $parameters['homePage'] = wire()->pages->get('/'); $parameters['buildVersion'] = BUILD_VERSION; $parameters['buildDate'] = BUILD_DATE; /** @var TemplateEngineFactory $twigEngine */ $twigEngine = modules('TemplateEngineFactory'); try { echo $twigEngine->render( $name, $parameters ); } catch (Exception|Error $e) { // Catching everything if (wire()->config->debug) // If debug, throw the error with stack trace throw new Error("{$e->getMessage()}\n{$e->getTraceAsString()}"); wire()->log->error($e); $parameters['errorPage'] = wire()->page->path; try { // Try to render my error template, that shows something nicer for users. echo $twigEngine->render('error', $parameters); } catch (Exception|Error) { // It may happen, rarely, that the error is located at a lower level in my Twig structure (inheritance...), // so I display a very basic template that uses no code and can't fail. echo $twigEngine->render('error-safe', $parameters); } } } }
  2. @SIERRA There's no problem here for me. CSS are loaded first so styles are available when content is loaded. https://web.dev/articles/critical-rendering-path/render-blocking-css
  3. Do you still have the warning when removing this styles?
  4. So you go on an admin page that contains a CKEditor and you get this error? Do you have some hooks that target CKEditor, or some special configuration for the CKEditor? Plugins, other modules that interact with it?... The code that triggers this error is: public function set($key, $value) { // convert extraPlugins string to array // used to be stored as a string in older versions if($key == 'extraPlugins' && is_string($value)) { $value = str_replace(' ', '', $value); $value = explode(',', $value); } else if($key == 'extraAllowedContent') { $value = str_replace(array("\r\n", "\n"), "; ", trim($value)); // trim() here receives a null value } else if($key == 'configName') { $this->configName = $value; } return parent::set($key, $value); } So this error happens when using "extraAllowedContent" and passing null as value. What you could do is editing this code and add a throw and look at the stacktrace to see what is calling this function with a null value (if $config->debug = true stack trace is directly shown on page): public function set($key, $value) { // convert extraPlugins string to array // used to be stored as a string in older versions if($key == 'extraPlugins' && is_string($value)) { $value = str_replace(' ', '', $value); $value = explode(',', $value); } else if($key == 'extraAllowedContent') { $value = str_replace(array("\r\n", "\n"), "; ", trim($value)); // trim() here receives a null value if ($value === null) throw new Exception('Check the stack trace!'); // trigger stack trace } else if($key == 'configName') { $this->configName = $value; } return parent::set($key, $value); }
  5. Really? 🤔 Maybe check the root directory you set in Apache config. It looks like it's targeted on mysite/site/templates/ instead of mysite/. Personally I use relative paths in CSS (url('../font/NotoSansDisplay-Regular.ttf')), but that doesn't matter, if I enter url('/site/templates/font/NotoSansDisplay-Regular.ttf') it works fine too since Apache root directory is set on parent directory of /site/.
  6. I would just use if ($page->isNew()). This is true when we are on the very first page form with only the title and name fields. Then it's false. This is the same as if (!$page->id).
  7. I would say the easiest is to add an "edit bookmark" to this page, it requires no module or hook nor moving the page in a specific location. Go to modules page Click the tab Configure Find the module Page Edit and click Configure Check to enable bookmarks Go to menu Pages > Edit > Bookmarks Add the bookmark for your page with the corresponding user role (select everyone if no specific role is necessary) Now you can access this page with menu Pages > Edit > Your page
  8. I see, this is probably the module "Page Title (Multi-Language)", I'm not using it, and the documentation talks about these active checboxes.
  9. The problem, for what I understand, is that you are asking for links that open in another tab. It's simple, @Jan Romero already answered the question. But then you say you need a redirect, but a redirect always change the current page URL, it's never opening in another tab. We are not talking about ProcessWire limitations but web standards. Maybe just be more precise on what you want, or maybe it's just me who doesn't understand... I asked ChatGPT what you need (with a link to this topic), and here is what he answered to your request, a JS script that automatically open a new tab on the wanted URL: echo "<script type='text/javascript'> window.open('{$page->external_url}', '_blank'); window.location.href = '{$page->some_other_url}'; </script>";
  10. I don't have theses active checkboxes in my multi-language pages, maybe you are using a specific module and that could help to mention it in your original post? Or is it an old PW version? I have no idea here. ?
  11. Why is it not constructive? Sorry that you interpret my comment that way. I've also read the output strategies tutorials and explanations were clear to me, so if you think "they don't make much sense" and you "struggle to read and comprehend the more complex code" I think you lack some PHP background. Maybe I'm wrong, it seems you are saying the problem is not about PHP knownledge, maybe you could explain so we can be more precise in the help we give to you.
  12. I'm curious, where in PW do you see a list of languages that are active or not for a page? I see nothing like this in my multi-language site but maybe you are using a specific module?
  13. So the next step is probably to learn PHP more. ?
  14. Wouldn't these two statements be contradictory? ? A redirection always change the current page. What you need is a link with target='_blank' like @Jan Romero wrote.
  15. Like Ryan said, the error message is about your database credentials, not the ProcessWire password. Connection with database can't be established because login or password is wrong, they are the same that you use with PhpMyAdmin, maybe login is "root" without password. So I suppose you don't use a versioning system like Git? Take a look at it after solving your issue, and you will never fear a file loss again. ^^
×
×
  • Create New...