-
Posts
1,065 -
Joined
-
Last visited
-
Days Won
11
Everything posted by Zeka
-
Calculate estimated reading time of content inside matrix field
Zeka replied to Zeka's topic in General Support
@elabx Thanks for idea. $repeater_fields = $this->wire('fields')->get('builder')->repeaterFields; $text_based_fields = $this->wire('fields')->find("id=" . implode($repeater_fields, '|') . ', type=FieldtypeTextarea|FieldtypeText|FieldtypeTextareaLanguage|FieldtypeTextareaLanguage'); $search_fields = $text_based_fields->implode('|', 'name'); $page->builder->find("{$search_fields}!=''")->each(function ($item) use (&$content, $search_fields) { $content .= $item->get($search_fields); }); Now I need to get it work with different langauges. -
Hi! I need to calculate estimated reading time for all of content inside all text extended fields inside repeater matrix field. That's how I do it now, but sometime I forgot to update selector when fields are changed for some of matrix types. /** * Calculate and save field value of estimated reading time */ public function calculateReadingTime($page) { $sanitizer = $this->wire('sanitizer'); $content = ''; $page->builder->find('body|title|otherfields!=""')->each(function ($item) use (&$content, $sanitizer) { $content .= $item->get('body|title|otherfields'); }); $page->readtime = $this->calculateEstimatedReadingTime($content); } That's why I was trying to use selector by Fieldtypes that was introduced in 3.0.91 with no luck $page->builder->find('FieldtypeText.extends!=""')->each(function ($item) use (&$content, $sanitizer) { $content .= $item->get(...); }); So the question is there more optimal way of doing it where I don't need to enter names of fields manualy?
-
@neonwired Have you tried to use $files->render() instead?
-
Page Hit Counter – Simple Page View Tracking
Zeka replied to David Karich's topic in Modules/Plugins
@David Karich Thanks again for the module. What do you think about adding an option to manually load js scripts from a custom folder?- 111 replies
-
- hitcounter
- tracking
- (and 4 more)
-
Hi @DooM Have you tried to use $files->rmdir ? https://processwire.com/api/ref/wire-file-tools/rmdir/
-
Hi. Using 'explode' on newly created WireArray doen't do anything: but 'each' method works Am I missing something? Thanks
-
Hi. Currently, I'm building a new multilanguage site. There are two languages: Russian (default - /ru/) and Ukrainian ( non-default - /ua/). In Languages Support - Page Names module I set 'No - Root URL performs a redirect to: /name/' for 'Default language homepage URL is same as root URL?' setting. Due to some new changes in language regulation from the government after some time, I will need to change the default language to Ukrainian. Currently accessing root domain I get redirect to /ru/. I thought that changing language for the guest user will be enough to get a redirect from '/' to '/ua/' on initial load, but it still redirects to '/ru/'. Is there is a way to get what I need without touching names for home page? Thanks.
-
https://processwire.com/api/ref/pages/get-by-path/
- 1 reply
-
- 2
-
-
Maybe you can hook to Page::viewable, so all methods like $pages->find which filters access conteroll will also filter such pages $this->addHook('Page::viewable', function($event) { if($this->wire('pages')->saas_id !== $this->wire('user')->saas_Id) { $event->return = false; } });
-
@Smoo Take a look at documentation for Pagefiles https://processwire.com/api/ref/pagefiles/ You can loop throught like // Traversing and outputting links to all files foreach($page->files as $name => $pagefile) { echo "<li><a href='$pagefile->url'>$name: $pagefile->description</a></li>"; }
-
Hi. There ProcessPageEditLink where we can specify some options for links. But, in my case, every link gets also 'noreferrer', 'noopener' and doesn't get 'external' class. If I'm not mistaken, I remember that I have setup this elsewhere, but can't remember where)) Are there options somewhere else? Why 'external' class doesn't populate?
-
@dragan, @wbmnfktr Sorry, it's not the site I'm working on, its just an example what I need. ☺️ Basicaly speaking I can't figurate how to transform page array to list separeted by days.
-
Hi. I need to implement an infinite scroll feature for a news site. There is no problem in the infinite scroll feature, but list of news should be separated with dates, like on screen image The working example you can find here. Sadly, but I can't figurate out where to start. Any ideas are much welcome. Thanks.
-
Ok, so it actually works with $today = strtotime('today'); setViewData([ 'news' => $news->explode(function ($news_item) use ($today) { return WireData([ 'title' => $news_item->title, 'date' => $news_item->if("publish_from>=$today ", 'yes', 'no'), 'link' => $news_item->url ]); }) ]); So maybe somebody can explain why it doesn't work with 'publish_from>=today'?
-
Hi. I'm have used $page->if several times and find it quite useful. Today I tried to output some string depend on date field, like setViewData([ 'news' => $news->explode(function ($news_item) { return WireData([ 'title' => $news_item->title, 'date' => $news_item->if('publish_from=today', 'yes', 'no'), 'link' => $news_item->url ]); }) ]); It returns 'no' for all items, but it should return yes for some of them. I have tested it with 'created' field and it also doesn't work pages('id>1000')->each(function ($item) { d(date("Y-m-d", strtotime('today'))); d(date("Y-m-d", $item->created), $item->if('created=today', 'yes', 'no')); }); Should I consider it as a bug and open an issue or I miss something and didn't understand the description of $key argument for $page->if() ?
-
@elabx Have you tried something like this? $selector = [ [ 'field' => 'template', 'value' => ['transaccion', 'pago'], 'operator' => '=', ], [ 'field' => 'pago_entit', 'value' => $user, 'operator' => '=', 'or' => 'test', ], [ 'field' => 'transaccion_representante_cliente', 'value' => $user, 'operator' => '=', 'or' => 'test' ], [ 'field' => 'sort', 'value' => '-created', ], [ 'field' => 'status', 'operator' => '<', 'value' => Page::statusTrash, ] ]; Not sure that is it even the right direction as it produces such selector dump: template=transaccion|pago, test@title=(41), test@email=(41), sort=-created, status<8192
-
@elabx $pages->find("template=transaccion|pago,(pago_entity=$user), (transaccion_representante_cliente=$user), sort=-created, status<" . Page::statusTrash); In this selector you are using OR-groups. There is not much documantation, but you can look at this topics https://github.com/processwire/processwire-issues/issues/264
-
if($config->ajax) { header('Content-Type: application/json'); echo $json; $this->halt(); // like die(); } else throw new Wire404Exception();
-
@elabx Could you please tell more how did you implement it? I have an autoload module, where I declare my hook public function init() { $this->addHook('ProcessPageEdit::executePreview', $this, 'testPreview'); } public function testPreview($event) { return 'test'; } But when I try to access 'admin/page/edit/preview' I got redirect to 'admin/page/edit/bookmarks/' and 'admin/page/edit/preview/' ( with slash) redirects to 'admin/page/edit/preview/bookmarks/bookmarks/bookmarks/bookmarks/'.
-
@bernhard And how you handle this requests? By hooks or custom methods?
-
@rjgamer There is Fieldset (Page) that have desired API behavior ( it doesn't installed by default). You can read about it here.
-
@dragan, @elabx, @Macrura Thanks for ideas. @Macrura Would be glad to see your module. Actually, my main intention is also to keep only Fieldtype and Inputfieldtype modules without additional modules. I have read somewhere that it is also possible to make requests to Input/Fieldtype config page. Have you tried this approach?
-
Very slow boot time - please help me find the cause!
Zeka replied to sodesign's topic in General Support
@Lutz Heckelmann Not help, but that what I got on the shared hosting -
Hi. I'm working on Inputfieldtype that have to get some data from pasted URL. Something like InputfieldURLChecker, but this one is using js, but mine should use AJAX request to some endpoint on the site to get data and then render additional information to the inputfield. So the question is how to provide such endpoint. I think that I can create a separete module that creates some page under Admin and make a request to this page. But I'm not sure that this is an optimal way, maybe there is something already in Inputfiled class or elsewhere that can help. Thanks in advance. Eugene.
-
Hi @tpr. Thanks for the module. I have spent some time to understand why the module doesn't work and the issue is that only ProcessPageEdit and ProcessProfile processes are allowed. But I have several process modules that handle page edit of custom page types. It would be great if we could control this option in the module config. There is $modules->findByPrefix("), so maybe you can provide such options with ASM select by $modules->findByPrefix("Process"); Thanks.