Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 09/19/2020 in all areas

  1. This week the core version remains at 3.0.166, but 3.0.167 should be ready by next week. The main reason I'm not bumping the version is just because a couple additional updates I want to get in 3.0.167 are started by not yet fully finished. Below is a look at what's been committed to the dev branch this week so far: Added custom Page class support for the Language class by implementing your own LanguagePage class that extends it (i.e. /site/classes/LanguagePage.php). Added a PR from MoritzLost with improvements to the CURL support in the WireHttp class. Added a new method to the Fieldtype interface named getMatchQuerySort() this method lets a Fieldtype module optionally manage the query when a $pages->find() requests a sort by a field/subfield handled by the Fieldtype. The first implementation of the getMatchQuerySort() method was added for FieldtypeOptions, which now lets you sort by option values or titles, despite those values and labels being in a separate table that the rest of ProcessWire doesn’t know about. Added a new getAfterLoginUrl() method to the Process module interface which lets Process modules optionally sanitize and validate request URLs to the module for a non-logged-in user. The resulting URL can be automatically redirected to once the user has logged-in. While the method has been added and implemented in several core Process modules, it is not yet used by the core after login—that will come next week in 3.0.167. Previously the only aspect of an admin URL that could survive login was an “id” integer in the query string. This week there were also several optimizations and improvements made to the PageFinder class and resolutions to 4 issue reports. Thanks for reading, have a great weekend!
    4 points
  2. @teppo and @bernhard Please try the attached main module file. With this version, you can simply add your panel to your module directory structure eg: /site/modules/TestModule/TracyPanels/TestThirdPartyModule.php Make sure the class name of the panel in this example is: TestThirdPartyModulePanel That should be all you need. Not super well tested so let me know if you find any problems or have any suggestions. If everything looks good, I'll commit the changes to the repo. TracyDebugger.module.php
    2 points
  3. Sounds like a minor thing in the end just to finish the post, unless it's your issue, your site falls apart without it being solved) Thanks!
    2 points
  4. Nope. It's never been possible. You must be confusing this with something else. Nothing to do with ProcessWire. Many (most?/all?) languages have variable scope. $config is outside the variable scope of myfunction(). myfunction() doesn't know what config is. You have to tell it. Having a namespace declaration has nothing to do with it. namespace ProcessWire; // alternative 1: use the global wire() function - @see: https://processwire.com/api/ref/functions/wire/ function myfunction() { echo wire('config')->paths->assets; // no error } // alternative 2: pass in $config function myfunction2($config) { echo $config->paths->assets; // no error } alternative 3: functions API - e.g. https://processwire.com/api/ref/functions/config/ @see also: https://processwire.com/api/ref/functions/
    1 point
  5. Thanks! Somehow the directory associated with a domain on our hosting account was deleted (still not clear on how that happened), resulting in a 500 error when visiting the site. I restored the folder and all its contents, which only rewarded us with a 403 error as I described in my original post. When I reached out to my host's support, they said "Reviewing, it looks like the ownership of the folder was not correct. We adjusted this and the website is now online." Hopefully that helps if anyone else's directories randomly go missing! Wish I knew how it happened.
    1 point
  6. https://processwire.com/docs/fields/select-options-fieldtype/#manipulating-options-on-a-page-from-the-api
    1 point
  7. I did. It turned out to be a setting on the webhost's end and they were able to fix it. Thanks! Sorry for taking up space here, but I was in a bit of a panic.
    1 point
  8. I don't remember why there are all these checks in hookAfterTemplateRender, but in such way it could identify a template that was used for rendering of the current page
    1 point
  9. @Ivan Gretsky I am not sure that this will help, but for one project I been using these hooks for a similar task. Maybe it will give you some ideas. public function init() { $this->addHookBefore('PageRender::renderPage', $this, 'hookBeforePageRenderTemplater'); $this->addHookAfter('TemplateFile::render', $this, 'hookAfterTemplateRender'); $this->wire('config')->ignoreTemplateFileRegex = "/(\.before\.)|(\.after\.)|(\.{$this->template_files_suffix}\.)|(^_)/"; } public function hookBeforePageRenderTemplater($e) { $event = $e->arguments(0); $page = $event->object; if ($page->template->name == 'admin') return; $options = $event->arguments(0); $template = $page->template; $options['prependFiles'] = [ "{$template}.before.php", "_init.php", ]; $options['appendFiles'] = [ "{$template}.after.php", "_after.php", ]; $event->setArgument(0, $options); } public function hookAfterTemplateRender($event) { if ($this->wire('page') == null) return; if (strpos($event->object->filename, 'TracyDebugger') !== false) return; if (str_replace('site/assets/cache/FileCompiler/', '', $event->object->filename) !== $this->wire('page')->template->filename) return; if (strpos($_SERVER['REQUEST_URI'], $this->wire('config')->urls->admin) === 0 || $this->wire('page')->template->name == 'admin') return; $template = $event->object; $options = $template->options; if (is_array($options) && array_key_exists('pageStack', $options)) { $view = $this->wire($this->api_view_var); $layout = $this->wire($this->api_layout_var); $page = $this->wire('page'); $page_template = $page->template; if ($template->halt) { return; }; if (empty($options['pageStack']) && $page_template->templater_url_segments) $this->wire('session')->redirect($page->url); $template_name = ($page->template->altFilename) ? $page->template->altFilename : $page->template->name; $view_file = $this->getViewFilePath($template_name); if (is_file($view_file)) { $view->setFilename($view_file); } else { throw new WireException("View file for this page template ({$view_file}) does not exist"); } $event->return = $event->return . $layout->render(); } }
    1 point
  10. No direct answer from me) Just googled that and this seems to be something you might want to take a look at.
    1 point
  11. Maybe something as simple as this will do? if(isset($input->get->q) && !empty($input->get->q)) { ...
    1 point
  12. It's possible with a hook. In the "List of fields to display in the admin Page List" setting for the template, enter a string that identifies where the value from the first repeater will go, e.g. first_repeater_datetime. Don't put the normal { } delimiters around this string. Then add a hook like this in /site/ready.php: $wire->addHookAfter('ProcessPageListRender::getPageLabel', function(HookEvent $event) { $page = $event->arguments(0); $out = $event->return; if($page->template == 'your_template') { $datetime = ''; if($page->datetimes->count) { $first_item = $page->datetimes->first(); $datetime = $first_item->date . ' ' . $first_item->time; } $event->return = str_replace('first_repeater_datetime', $datetime, $out); } });
    1 point
  13. I solve the problem by overriding the LanguageSupportPageNames core module. 1. Copy the LanguageSupportPageNames.module from wire/modules/LanguageSupport/ to site/modules/ 2. Change the line if(!$setLanguage) $setLanguage = $languages->get('default'); to (for example, if you want to redirect some users to chinese site) $user_lang = explode(",", $_SERVER['HTTP_ACCEPT_LANGUAGE'])[0]; if($user_lang == 'zh-TW' || $user_lang == 'zh-HK' || $user_lang == 'zh-CN' || $user_lang == 'zh-SG') { if(!$setLanguage) $setLanguage = $languages->get('chinese'); //language name that you want to redirect from the above language code }else{ if(!$setLanguage) $setLanguage = $languages->get('default'); // else go to default language } 3. Go to Admin > Modules and refresh modules. Choose to use module inside site/module/. In this way, when no language segment is entered in the URL, the user will be redirected according to their HTTP_ACCEPT_LANGUAGE header. On the other hand, URL with language segment will not make any redirect.
    1 point
×
×
  • Create New...