-
Posts
303 -
Joined
-
Last visited
Everything posted by valan
-
@Some - action($item) method gets only one item as an argument. There is executeMultiple($items) but populating $items beforehand may lead to memory issues. Is there some PW core $class->method($selector) that can get items selector as argument and run PageAction in batches? Or, how to wrap @LostKobrakai code in a cycle that handles items in batches? There is "custom" solution, proposed by @WillyC. Is there another solution that already exists in PW core/how code looks like?
-
@LostKobrakai - what if you need to cycle a lot of pages and run PageAction inside cycle? Should @WillyC approach be used or there exists some special method for this?
-
Wasn't aware of uncacheAll() - sounds as what's needed if you cycle a lot of pages and do smth with page fields (e.g. modifying/saving/etc). Also never used PageFinder + direct SQL call. It's probably better option if you need to perform simple get operation (like sum). Good post - will be useful for all who develop sites with a lot of pages. Does anybody know if it is possible to use PageActions introduced with ProcessLister - in background (w/o frontend)? It works perfectly in frontend and I use it for mass changes, but don't know if the same can be done w/o frontend.
-
Normally if you'd like to sum values of some page field for required pages you do smth like this: $mypages = wire('pages')->find($myselector); foreach ($mypages as $mypage) $sum += $mypage->amount; Assume you have 1000000 pages returned from selector. In this case, approach above doesn't work due to server memory limits. In my case PHP 5.5 just silently stops w/o any error notification)) How this code should be transformed in order to cycle huge number of pages and do not hit memory limit?
-
How to get array of page ids by selector if there are 10000+ pages?
valan replied to valan's topic in API & Templates
3 years PWired, but PW still surprises. Right marriage. -
How to get array of page ids by selector if there are 10000+ pages?
valan replied to valan's topic in API & Templates
@LostKobrakai - thanks! I know loadPages, but returnVerbose is smth new... haven't seen any documentation on it. Does it work in PW2.7? Will check myself.Thanks! -
I'd like to add FB-like messages and notifications to PW admin menu. FB-like means: - admin frontend: js script that each min sends ajax requests to the server and depending on response, updates admin menu item element of DOM. Messages and notifications behave similarly to what we have at FB. - backend: script(s) that processes ajax request and return notifications data. Notifications data is stored in user template. Just to give you an idea re notifications, few examples of notifications that gets some user with "sales" role: - System Task: Prepare quote for order 23451 - System Task: Callback to user 54321 at 12pm - System Info: Order 98567 has been cancelled - User Message: Hey, bro can't find you contact. Please call me. - etc... Qs: 1. what would be a "right" way to add such "non-PW" menu item to admin menu? Hook during admin menu rendering? 2. there is pre-installed notification field in user account. I'm interested to understand if I can use it w/o custom coding OR extend existing core classes? Where to start digging? or where I can read more about it?
-
Hello PW-friends! Let me share some thoughts re roadmap that emerged together with the development of mymechanic.ru site (currently 8K clients/30K visits per month). Initially it was a simple "info" site and PW was ideal for it, but when business has grown, I start to miss some functionality. I understand that this functionality may not be necessary for current PW sites or even PW concept, but anyway I would be grateful if you could share thoughts on the following: 1. simultaneous page editing capability. There are several roles that work with page and I have to remind them about queue in order to ensure that edits are saved properly. It is not effective. To unlock the capability, all fields and even admin layout should be able to update in "real-time" as soon as there are changes at server. Also there should be field-level lock/sync mechanism. I guess it is big core code refactoring. 2. event-driven admin (page editing, etc). With observers, controllers, routers etc - all you need when you develop frontend SPA. Of course, this can be done w/o PW internal features but I see great opportunity here for PW. By the way, check this framework - http://riotjs.com/ I believe it aligns well with PW ideas of best performance and simplicity. 3. advanced filtering in listers. E.g. the dream is filters like this: {myfield1.subfeild1.subfield1.date1} > {myfield2.subfeild2.subfield2.date2} - with indefinite levels depth, fully customizable on left and on right sides of condition, even with PHP snippets option. It is something that actually I haven't seen anywhere else - something really unique and powerful. I also have some other thoughts but I don't want to overload. These are top-3 in my mind. Thanks.
- 1 reply
-
- 3
-
-
I also vote for bug. IMO it does make sense as "field group management" is what Fieldset about (or what is the purpose of Fieldset?).
-
After upgrade to 2.7.2 all FieldsetOpen fields that were hidden in template - start to show unhidden "child" fields that are inside them. Before upgrade these fields were hidden too. Is it a bug or feature?
-
I'm rendering some markup in page edit UI with help of hook ProcessPageEdit::buildFormContent (example here: https://processwire.com/talk/topic/10539-how-to-render-runtime-markup-custom-php-snippet-in-page-edit-interface/) It works OK until you decide to use ajax-driven Fieldsets. Q1: how to render runtime markup in page edit interface if markup is inside of ajax-driven Fieldset? Q2: how to "ajax"-inize custom Inputfields/Fieldtypes?
-
@adrian thanks! I've found one more solution that addresses own Q and does not require code. It is as simple as (1) setting "Don't allow unpublished pages" in template advanced settings and (2) adding role-publish permission in template access tab. As a result, there are no unpublished pages => no "pub/unpub" buttons while user in role is allowed to edit published pages.)
-
How to assign a permission (to the role) that allows only published pages (of some template) editing AND does not allow editing of unpublished pages? E.g. I want to disable pub/unpub action button both in tree and in Listers for some role/template, but leave editing.
-
One more point - FieldtypeMulti extends Fieldtype, so hook to Fieldtype::savePageField catches both events.
-
Ivan, thank! Just tested code - works perfectly.
-
@Ivan, thanks - I missed somehow intro of conditional hooks - looks like syntax sugar) @LostKobrakai, thanks for advice with two hooks - it is not so obvious. Two Qs left: 1. How to get old and new values from Pages::savedField? I see only $page and $field among args... sorry still can't catch logic here. 2. What if you want to check new field value - compare it with old value and prevent saving on some condition? e.g. Which hook to use in this case? and I guess set it with addHookBefore? Again - I'm saving from API with $page->save($field) and $page->save()
-
As far as I understand "Pages::saved" is called on $page->save(). Is it also called when field is saved from API, e.g. called on $page->save($field, $value) and on $page->setAndSave($field, $value)?
-
There is a need to send mail when (1) some fields (2) in some template (3) at some page (4) were changed from "one value" to "another value" (5) via API (e.g. not only from admin). Questions: 1. Please could you help with right hook for that? "Fields::save"? 2. How to get $page from hook method, e.g. $page where field is planned to be changed? 3. Finally, would this piece of code work? - specifically getting old and new values, plus messaging to admin (in case changes are not from API) public function init() { $this->addHookAfter("Field::save", $this, "validateAndMail"); } public function validateAndMail($event) { $field = $event->object; if($field->name == 'my_field') { $page = ? // some code here to get page where this field is planned to be saved $is_this_page = $page->id === 12345; // needed page $is_this_template = $page->template->name === 'my_template'; // needed template $oldValue = $page->get($field->name); $newValue = $field->value; if($oldValue === "foo" && $newValue==="bar" && $is_this_page && && $is_this_template) { my_mail_func($page, $oldValue, $newValue); $this->message($this->_("$newValue !!!")); // would it work in case of changes from admin? } } }
-
Ups... my mistake. Missed own syntax error. Closed. @kongondo, @LostKobrakai - thanks!
-
kongondo, real name also doesn't work (( The same exception is generated: Exception: SQLSTATE[42S22]: Column not found: 1054 Unknown column '_sort_myfield_data.data' in 'mytemplate clause'
-
This subfield is stored in db. Do you mean that this should work? Not sure but will give a try. $query = 'template=mytemplate'; $result = wire('pages')->find($query)->sort('myfield.mysubfield');
-
Does 'sort' support subfields? I'm trying to sort pages like this: $query = 'template=mytemplate,sort=myfield.mysubfield'; $result = wire('pages')->find($query); It generates: Exception: SQLSTATE[42S22]: Column not found: 1054 Unknown column '_sort_myfield.mysubfield' in 'mytemplate clause' (in var/www/pw/wire/core/PageFinder.php line 298) E.g. is there any way to sort by subfields in a query?
-
@kongondo - thanks! Re notification - its already in your code: $field->error($this->_("That email $newEmail is already taken mate; go fishing! :-)"));
-
There is a need to prevent duplicate user emails, e.g. ensure that users have unique emails. This requires email uniqueness checks to be performed each time email field is going to be saved. Please could you help with right hook for that and get/set methods in function call? E.g. how to get "old" and "new" email values. How to skip saving OR save if email is unique? Simple piece of code is preferred over words.) Thanks! P.S. Also, it would be good it admin gets error notification when tries to save user page with duplicate email.