Jump to content

Zeka

Members
  • Posts

    1,065
  • Joined

  • Last visited

  • Days Won

    11

Everything posted by Zeka

  1. @flydev Thank a lot. You brought me to mind that I have been testing the performance of some queries and declared in the config. $config->dbCache = false; ?‍♂️
  2. @flydev Thank. Not a guru in SQL. MySQL 5.7.16 on a remote server. On the local server, I have 5.7.19 and I don't remember that I have such error. Is this error server specific?
  3. @HerTha Just curious is this code fails? $a_sel = [ ['sort', 'name'], ['limit', $limit_per_section], ['template', 'downfile'], ['title|name|indexer', '%=', $sanitizer->selectorValue($a_terms)] ]; $results = $pages->find($a_sel);
  4. Hi. I'm getting this error SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.id FROM `pages` JOIN field_banner_categories AS field_banner_categories O' at line 7 with this selector $this->wire('pages')->find("banner_position=sidebar, (banner_categories|banner_sections=$page), (banner_custom_pages=$page)"); banner_position - Select Options field banner_categories, banner_sections, banner_custom_pages - Page reference fields. This selector produces such SQL queries: banner_categories|banner_sections=1057 ---------------------------- SELECT SQL_NO_CACHE pages.id FROM `pages` LEFT JOIN field_banner_categories AS field_banner_categories ON field_banner_categories.pages_id=pages.id AND ((((field_banner_categories.data='1057') ) )) LEFT JOIN field_banner_sections AS field_banner_sections ON field_banner_sections.pages_id=pages.id AND ((((field_banner_sections.data='1057') ) )) WHERE ((((field_banner_categories.data='1057') ) ) OR (((field_banner_sections.data='1057') ) ) ) banner_custom_pages=1057 ---------------------------- SELECT SQL_NO_CACHE pages.id FROM `pages` JOIN field_banner_custom_pages AS field_banner_custom_pages ON field_banner_custom_pages.pages_id=pages.id AND ((((field_banner_custom_pages.data='1057') ) )) banner_position=sidebar, =(banner_categories|banner_sections=1057), =(banner_custom_pages=1057), status<1024 ---------------------------- SELECT SQL_NO_CACHE pages.id,pages.parent_id,pages.templates_id FROM `pages` JOIN field_banner_position AS field_banner_position ON field_banner_position.pages_id=pages.id AND (((field_banner_position.data='1' ) )) WHERE (pages.status<1024) AND ( pages.id IN ( SELECT SQL_NO_CACHE pages.id FROM `pages` LEFT JOIN field_banner_categories AS field_banner_categories ON field_banner_categories.pages_id=pages.id AND ((((field_banner_categories.data='1057') ) )) LEFT JOIN field_banner_sections AS field_banner_sections ON field_banner_sections.pages_id=pages.id AND ((((field_banner_sections.data='1057') ) )) WHERE ((((field_banner_categories.data='1057') ) ) OR (((field_banner_sections.data='1057') ) ) ) ) OR pages.id IN ( SELECT SQL_NO_CACHE pages.id FROM `pages` JOIN field_banner_custom_pages AS field_banner_custom_pages ON field_banner_custom_pages.pages_id=pages.id AND ((((field_banner_custom_pages.data='1057') ) )) ) ) GROUP BY pages.id I thought that it can be relative to "OR" selector banner_categories|banner_sections=$page So I tried $this->wire('pages')->find("banner_position=sidebar, (banner_sections=$page), (banner_custom_pages=$page)"); It also produces the same error. Any thought? Thanks.
  5. @SoccerGuy3 Glad that it helped. The name of your button is not 'submit', but 'submit_name', but in your initial code you check '$this->input->post->submit'. $f->attr('name', 'submit_save'); Also if you want to make your code more PWish you can rewrite it with https://processwire.com/api/ref/wire-database-p-d-o/
  6. /** Executed when root url for module is accessed */ public function ___execute() { $form = $this->buildForm(); if($this->input->post->submit) { <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $result = $this->processForm($form); return $result; } else { return $form->render(); } }
  7. @SoccerGuy3 $this->wire('input')->post->submit_save Have you tried TracyDebbuger?
  8. @HerTha I use such code: if (input('get', 'q')) { $query = input('get', 'q', 'text'); input()->whitelist('q', $query); $selector = [ ['template', 'post'], ['title|builder.post_wysiwyg|builder.blockquote_wysiwyg', '%=', $query], ['limit', '10'] ]; } and it also works with '!' without errors. Consider using selectors as arrays as it more clear way and have on a small benefit that you don't have to use $sanitizer->selectorValue()
  9. @BillH Also if you are familiar with SQL you can get recent images directly from DB with one query and then find corresponding pages if you need some information from them. There is RockFinder module that can perform faster searches in some scenarios (complicated dashboards etc.)
  10. @BillH Have you tried to use 'findMany' method? Does it make different?
  11. @flydev Yes, of course, I can use hasPermission, but I thought that if we have $page->publishable(), $page->deleteable() ( these checks also relies on page-publish and page-delete permissions along with other factors), we should have separate method for hide/unhide.
  12. Hi. I'm building custom UI for editors and I need to check if a user is able to hide and unhide pages (page-hide permission). I thought that $page->listable(); is intended to check this, but it returns true whether a user has page-hide permission or not. So what is the right way to check it?
  13. @alemachado processInputAddPages is a hookable method, so you can make a hook without modifying the core. Also, make sure that all languages are active on parent page where you add pages from the page reference field, I'm not sure that it gonna help/
  14. @pout You can hook to Pages::added. It will fire only once when the user is created. wire()->addHookAfter('Pages::added', function($event) { $page = $event->arguments(0); if($page->template == "user"){ $user_id = $event->arguments(0)->id; } }); From this hook, you can create user's page wire()->addHookAfter('Pages::saved', function($event) { $page = $event->arguments(0); if($page->template == "user"){ $user_id = $event->arguments(0)->id; $savedUser = $page; $userpage = wire('pages')->find("parent=/parentpage, name=page-for-user-".$user_id); if ( count($userpage) == 0 ) { $parent = wire('pages')->get('/parentpage'); $page = new Page(); $page->template = 'Lektionen'; $page->name = $pages->names()->uniquePageName('page-for-user-' . $user_id, $parent); $page->parent = $parent; $page->title = $savedUser->name; $page->save(); } } });
  15. @pout Why just not use user IDs? Also, you can use the Pagenames class that was introduced in 3.0.111 like $page->name = $pages->names()->uniquePageName('user-' . $user->id, $users_parent); https://processwire.com/blog/posts/pw-3.0.111/
  16. @Gadgetto There is nothing special in using preloadFor method. All you have to do is to call it before any calls of get method $cache->preloadFor($this->className()); As you can see I have a lot of chunks of cache namespaced with TestsDashboard. Instead of multiple select queries 67 SELECT name, data FROM caches WHERE (name=:name1) AND (expires>=:now OR expires<=:never) -- cache.get(TestsDashboard__test-intro-2725, null) 68 SELECT name, data FROM caches WHERE (name=:name1) AND (expires>=:now OR expires<=:never) -- cache.get(TestsDashboard__test-intro-2726, null) 69 SELECT name, data FROM caches WHERE (name=:name1) AND (expires>=:now OR expires<=:never) -- cache.get(TestsDashboard__test-intro-2727, null) 70 SELECT name, data FROM caches WHERE (name=:name1) AND (expires>=:now OR expires<=:never) -- cache.get(TestsDashboard__test-intro-2728, null) 71 SELECT name, data FROM caches WHERE (name=:name1) AND (expires>=:now OR expires<=:never) -- cache.get(TestsDashboard__test-intro-2729, null) 72 SELECT name, data FROM caches WHERE (name=:name1) AND (expires>=:now OR expires<=:never) -- cache.get(TestsDashboard__test-intro-2730, null) 73 SELECT name, data FROM caches WHERE (name=:name1) AND (expires>=:now OR expires<=:never) -- cache.get(TestsDashboard__test-intro-2731, null) 74 SELECT name, data FROM caches WHERE (name=:name1) AND (expires>=:now OR expires<=:never) -- cache.get(TestsDashboard__test-intro-2732, null) 75 SELECT name, data FROM caches WHERE (name=:name1) AND (expires>=:now OR expires<=:never) -- cache.get(TestsDashboard__test-intro-2733, null) 76 SELECT name, data FROM caches WHERE (name=:name1) AND (expires>=:now OR expires<=:never) -- cache.get(TestsDashboard__test-intro-2734, null) 77 SELECT name, data FROM caches WHERE (name=:name1) AND (expires>=:now OR expires<=:never) -- cache.get(TestsDashboard__test-intro-2735, null) 78 SELECT name, data FROM caches WHERE (name=:name1) AND (expires>=:now OR expires<=:never) -- cache.get(TestsDashboard__test-intro-2736, null) 79 SELECT name, data FROM caches WHERE (name=:name1) AND (expires>=:now OR expires<=:never) -- cache.get(TestsDashboard__test-intro-2737, null) 80 SELECT name, data FROM caches WHERE (name=:name1) AND (expires>=:now OR expires<=:never) -- cache.get(TestsDashboard__test-intro-2738, null) 81 SELECT name, data FROM caches WHERE (name=:name1) AND (expires>=:now OR expires<=:never) -- cache.get(TestsDashboard__test-intro-2739, null) 82 SELECT name, data FROM caches WHERE (name=:name1) AND (expires>=:now OR expires<=:never) -- cache.get(TestsDashboard__test-intro-2740, null) 83 SELECT name, data FROM caches WHERE (name=:name1) AND (expires>=:now OR expires<=:never) -- cache.get(TestsDashboard__test-intro-2741, null) 84 SELECT name, data FROM caches WHERE (name=:name1) AND (expires>=:now OR expires<=:never) -- cache.get(TestsDashboard__test-intro-2742, null) 85 SELECT name, data FROM caches WHERE (name=:name1) AND (expires>=:now OR expires<=:never) -- cache.get(TestsDashboard__test-intro-2743, null) 86 SELECT name, data FROM caches WHERE (name=:name1) AND (expires>=:now OR expires<=:never) -- cache.get(TestsDashboard__test-intro-2744, null) using preloadFor I will load them to memory from DB only with one query and then all next calls of get will load them not from DB, but from memery SELECT name, data FROM caches WHERE (name LIKE :name1) AND (expires>=:now OR expires<=:never) -- cache.get(TestsDashboard__*, null)
  17. @VeiJari What do you mean under "temporary file"?
  18. Hie @tiefenbacher_bluetomato You should be able to do it in this way $first_image = $page->images->first(); $first_image->description('de'); As pageimage class extends pagefile.
  19. Hi @ti-no For that, you can use hooks. First, take a look at the documentation https://processwire.com/docs/modules/hooks/ There is a list of core modules and classes and their hookable methods http://somatonic.github.io/Captain-Hook/
  20. @Gadgetto Maybe you can check if there is any information in DB and use getDefaults() method as a fallback. https://github.com/processwire/processwire/blob/341342dc5b1c58012ae7cb26cffe2c57cd915552/wire/core/ModuleConfig.php#L60 Also, take a look at the description of the getDefaults method https://github.com/processwire/processwire/blob/341342dc5b1c58012ae7cb26cffe2c57cd915552/wire/core/ModuleConfig.php#L55
  21. Or you can make such replace only for your email body text.
  22. Are you familiar with Textformatter modules? https://processwire.com/talk/topic/10906-ckeditor-absolute-image-path-possible/
  23. You can choose between absolute and relative link types in ProcessPageEditLink module settings.
  24. ProFields (especially Matrix Field) and ProCache.
×
×
  • Create New...