Jump to content

Zeka

Members
  • Content Count

    849
  • Joined

  • Last visited

  • Days Won

    7

Zeka last won the day on November 26 2019

Zeka had the most liked content!

Community Reputation

898 Excellent

About Zeka

  • Rank
    Hero Member
  • Birthday 04/12/1989

Profile Information

  • Gender
    Male
  • Location
    Kiev, Ukraine

Recent Profile Visitors

3,326 profile views
  1. Do you use MarkupPagerNav module? If so, there is 'baseUrl' property where probably you should pass your modified page URL
  2. @franciccio-ITALIANO You may also consider to you October CMS (Laravel based CMS) + Shoppoholic as ecommerce solution. There are also a lot of modules free and commercial.
  3. 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
  4. @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(); } }
  5. @maddmac Sorry, but no. I do not use FormBuilder.
  6. https://processwire.com/docs/start/variables/input/ https://processwire.com/blog/posts/pw-3.0.125/ https://processwire.com/api/ref/wire-input/ $wire->addHookAfter('InputfieldPage::getSelectablePages', function($event) { if($event->object->name == 'myselect') { $temp = $this->wire('input')->get('temp', 'text', 'fallback-template'); $event->return = $event->pages->find('template=$temp'); } });
  7. @PWaddict Try to use $inputfield->set('maxFiles', 20);
  8. @clemens Try to $wire->addHookAfter(); https://processwire.com/docs/modules/hooks/#do-i-want-my-hook-to-run-before-or-after-the-method-i-am-hooking-or-does-it-matter
  9. @Orkun I think that it is enoght to run it once if you have some issues or after update to PW >= 3.0.156. https://github.com/processwire/processwire/blob/master/wire/core/PagesParents.php#L485 Save method from PagesParents class executes on every page save and if it's necessary it will execute rebuildAll method. https://github.com/processwire/processwire/blob/master/wire/core/PagesParents.php#L502
  10. @franciccio-ITALIANO You can get it from DB in the "pages" table. Row where id = 2.
  11. Hi. After update to 3.0.163 and 3.0.164 selectors like pages('template=tag, title.data1022="", limit=10'); do not work. Could somebody confirm it? Thanks.
  12. Hi. For now I add flag at init.php and remove it in ready.php like // init.php if (strpos(sanitizer()->entities(input()->url()), 'some/page/')) { fields('somefield')->addFlag(Field::flagAutojoin); } // ready.php fields('somefield')->removeFlag(Field::flagAutojoin); But there are pages that not so easy to identify by URL. So far I couldn't find any suitable hook and probably it is the only way to do it, or I missed something? Thank!
  13. @ryan Just to make sure that I understand you correctly when a page with 'tour' or 'bike' template is saved this hook clears cache only /reviews/bike-tours/* and /reviews/boat-[name]/ segments. Cache for review page and all other segments stay untouched. If so, it looks like what I'm looking for. ProCacheStaticClear - is it something new in V4 or tripsite specific? Definitely it steps forward to save resources and more selective cache clearing process. But I would like to propose one more optimization relative to multilanguage setup. We also have two languages: Ukrainian as default and Russian as secondary. Only 40% of news have a translation to the Russian language, but when a page is saved and doesn't have translation (secondary language is not active) ProCache clears the cache for all Russian pages and listings. In our case, every news item page has tags, sections, categories, author reference fields (all these referenced pages also have pagination and language versions), could be listed in sitemaps, RSS feeds etc. So clearing cache for secondary language (probably hundreds (in some case thousand) of pages), when there are actually no changes for it could produce unnecessary load. I have found some example on tripsite.com where this optimization could be handy. https://www.tripsite.com/bike-boat/all/ - 106 Tours https://www.tripsite.com/br/bicicleta-barco/all/ - 65 Tours https://www.tripsite.com/es/bici-barco/all/ - 46 Tours I can assume that not all tours available on every language and when a new relevant page with template 'tour' is saved cache for all these URLs (pages) and URL segments is cleared regardless of Portugues or Espanol languages are active for the saved tour. What do you think?
  14. @ryan Thanks. I have two examples: -------------- I have an RSS page which uses RSS template. This page outputs the main RSS feed, also there are several allowed URL segemtns for this template such: rss/google-news/ rss/yandex-news/ rss/ukrnet/ etc. Each segment outputs platform-specific feed with different markup and pages that are listed in the feed (based on the selection from options field). So when any new post is published or saved cache for RSS page including its URL segments are cleared, but because new post could be listed only for Google News clearing cache for Yandex and Ukrnet segments is unnecessary. -------------- Next example I have sitemap page/template which outputs sitemaps index like: Based on URL segments I generate a sitemap for specific time period or template. The same thing here if new category or post is created I want to clear the cache only for relevant template URL segment or for segment that reprecent current month (there are several thousand posts per month so regenerating cache for each URL segment each time creates unnecessary load on the server).
×
×
  • Create New...